/******************************************************************************************
 * The contents of this file are subject to the SOURCE CODE AGREEMENT ("License Agreement")
 * which can be viewed at http://www.letrium.com/jetmobile-agreement
 *
 * BY DOWNLOADING AND/OR INSTALLING AND/OR USING THIS FILE YOU AGREE TO BE BOUND BY THE TERMS
 * OF THIS LICENSE AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE AGREEMENT,
 * PLEASE DO NOT DOWNLOAD, INSTALL, RUN, OR OTHERWISE USE THE SOURCES OF THE SOFTWARE.
 * Under the terms of the license, You shall not, among other things:
 * 1) permit, authorize, license or sublicense any third party to view or use
 * the Source Code; 2) sell, rent, lease, distribute, make available, publish or
 * otherwise transfer the Source Code; 3) develop Forked Software;
 * 4) use the Source Code for anything other than its intended, legitimate,
 * and legal purpose.
 *
 * You do not have the right to remove Letrium copyrights from the source code
 * or user interface.
 *
 * To the maximum extent permitted by applicable law, Letrium shall not be liable
 * to Licensee for any incidental, consequential, special, punitive or
 * indirect damages, including without limitation, damages for loss of profits,
 * business opportunity, data or use, incurred by Licensee or any third party,
 * even if it has been advised of the possibility of such damages.
 * Letrium makes no representations or warranties with respect to the Source Code.
 * All express or implied representations and warranties, including without
 * limitation any implied warranty of merchantability, of fitness for a particular
 * purpose, of reliability or availability, of accuracy or completeness of responses,
 * of results, of workmanlike effort, of lack of viruses, and of lack of negligence,
 * is hereby expressly disclaimed. Licensee specifically acknowledges that the Source Code
 * is provided "as is" and may have bugs, errors, defects or deficiencies.
 *
 * Copyright (C) 2012 Letrium ltd.; All Rights Reserved.
 ******************************************************************************************/
/*! jQuery Mobile v1.1.1 1981b3f5ec22675ae47df8f0bdf9622e7780e90e jquerymobile.com | jquery.org/license */
(function (l, t, k) {
    typeof define === "function" && define.amd ? define(["jquery"], function (E) {
        k(E, l, t);
        return E.mobile
    }) : k(l.jQuery, l, t)
})(this, document, function (l, t, k, E) {
    (function (a, c, b, d) {
        function e(a) {
            for (; a && typeof a.originalEvent !== "undefined";) a = a.originalEvent;
            return a
        }

        function g(b) {
            for (var e = {}, g, d; b;) {
                g = a.data(b, s);
                for (d in g)
                    if (g[d]) e[d] = e.hasVirtualBinding = true;
                b = b.parentNode
            }
            return e
        }

        function f() {
            y && (clearTimeout(y), y = 0);
            y = setTimeout(function () {
                G = y = 0;
                A.length = 0;
                F = false;
                H = true
            }, a.vmouse.resetTimerDuration)
        }

        function j(b, g, c) {
            var f, h;
            if (!(h = c && c[b])) {
                if (c = !c) a: {
                    for (c = g.target; c;) {
                        if ((h = a.data(c, s)) && (!b || h[b])) break a;
                        c = c.parentNode
                    }
                    c = null
                }
                h = c
            }
            if (h) {
                f = g;
                var c = f.type,
                    j, F;
                f = a.Event(f);
                f.type = b;
                h = f.originalEvent;
                j = a.event.props;
                c.search(/^(mouse|click)/) > -1 && (j = w);
                if (h)
                    for (F = j.length; F;) b = j[--F], f[b] = h[b];
                if (c.search(/mouse(down|up)|click/) > -1 && !f.which) f.which = 1;
                if (c.search(/^touch/) !== -1 && (b = e(h), c = b.touches, b = b.changedTouches, c = c && c.length ? c[0] : b && b.length ? b[0] : d))
                    for (h = 0, len = x.length; h < len; h++) b = x[h],
                f[b] = c[b];
                a(g.target).trigger(f)
            }
            return f
        }

        function h(b) {
            var e = a.data(b.target, u);
            if (!F && (!G || G !== e))
                if (e = j("v" + b.type, b)) e.isDefaultPrevented() && b.preventDefault(), e.isPropagationStopped() && b.stopPropagation(), e.isImmediatePropagationStopped() && b.stopImmediatePropagation()
        }

        function q(b) {
            var c = e(b).touches,
                d;
            if (c && c.length === 1 && (d = b.target, c = g(d), c.hasVirtualBinding)) G = N++, a.data(d, u, G), y && (clearTimeout(y), y = 0), z = H = false, d = e(b).touches[0], t = d.pageX, C = d.pageY, j("vmouseover", b, c), j("vmousedown", b, c)
        }

        function o(a) {
            H || (z || j("vmousecancel", a, g(a.target)), z = true, f())
        }

        function m(b) {
            if (!H) {
                var c = e(b).touches[0],
                    d = z,
                    h = a.vmouse.moveDistanceThreshold;
                z = z || Math.abs(c.pageX - t) > h || Math.abs(c.pageY - C) > h;
                flags = g(b.target);
                z && !d && j("vmousecancel", b, flags);
                j("vmousemove", b, flags);
                f()
            }
        }

        function v(a) {
            if (!H) {
                H = true;
                var b = g(a.target),
                    c;
                j("vmouseup", a, b);
                if (!z && (c = j("vclick", a, b)) && c.isDefaultPrevented()) c = e(a).changedTouches[0], A.push({
                    touchID: G,
                    x: c.clientX,
                    y: c.clientY
                }), F = true;
                j("vmouseout", a, b);
                z = false;
                f()
            }
        }

        function n(b) {
            var b =
                a.data(b, s),
                e;
            if (b)
                for (e in b)
                    if (b[e]) return true;
            return false
        }

        function k() {}

        function p(b) {
            var e = b.substr(1);
            return {
                setup: function () {
                    n(this) || a.data(this, s, {});
                    a.data(this, s)[b] = true;
                    l[b] = (l[b] || 0) + 1;
                    l[b] === 1 && J.bind(e, h);
                    a(this).bind(e, k);
                    if (M) l.touchstart = (l.touchstart || 0) + 1, l.touchstart === 1 && J.bind("touchstart", q).bind("touchend", v).bind("touchmove", m).bind("scroll", o)
                },
                teardown: function () {
                    --l[b];
                    l[b] || J.unbind(e, h);
                    M && (--l.touchstart, l.touchstart || J.unbind("touchstart", q).unbind("touchmove", m).unbind("touchend",
                        v).unbind("scroll", o));
                    var g = a(this),
                        c = a.data(this, s);
                    c && (c[b] = false);
                    g.unbind(e, k);
                    n(this) || g.removeData(s)
                }
            }
        }
        var s = "virtualMouseBindings",
            u = "virtualTouchID",
            c = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),
            x = "clientX clientY pageX pageY screenX screenY".split(" "),
            w = a.event.props.concat(a.event.mouseHooks ? a.event.mouseHooks.props : []),
            l = {}, y = 0,
            t = 0,
            C = 0,
            z = false,
            A = [],
            F = false,
            H = false,
            M = "addEventListener" in b,
            J = a(b),
            N = 1,
            G = 0;
        a.vmouse = {
            moveDistanceThreshold: 10,
            clickDistanceThreshold: 10,
            resetTimerDuration: 1500
        };
        for (var K = 0; K < c.length; K++) a.event.special[c[K]] = p(c[K]);
        M && b.addEventListener("click", function (b) {
            var e = A.length,
                g = b.target,
                c, d, f, h, j;
            if (e) {
                c = b.clientX;
                d = b.clientY;
                threshold = a.vmouse.clickDistanceThreshold;
                for (f = g; f;) {
                    for (h = 0; h < e; h++)
                        if (j = A[h], f === g && Math.abs(j.x - c) < threshold && Math.abs(j.y - d) < threshold || a.data(f, u) === j.touchID) {
                            b.preventDefault();
                            b.stopPropagation();
                            return
                        }
                    f = f.parentNode
                }
            }
        }, true)
    })(l, t, k);
    (function (a, c, b) {
        function d(a) {
            a = a || location.href;
            return "#" + a.replace(/^[^#]*#?(.*)$/,
                "$1")
        }
        var e = "hashchange",
            g = k,
            f, j = a.event.special,
            h = g.documentMode,
            q = "on" + e in c && (h === b || h > 7);
        a.fn[e] = function (a) {
            return a ? this.bind(e, a) : this.trigger(e)
        };
        a.fn[e].delay = 50;
        j[e] = a.extend(j[e], {
            setup: function () {
                if (q) return false;
                a(f.start)
            },
            teardown: function () {
                if (q) return false;
                a(f.stop)
            }
        });
        f = function () {
            function f() {
                var b = d(),
                    g = s(n);
                if (b !== n) p(n = b, g), a(c).trigger(e);
                else if (g !== n) location.href = location.href.replace(/#.*/, "") + g;
                j = setTimeout(f, a.fn[e].delay)
            }
            var h = {}, j, n = d(),
                k = function (a) {
                    return a
                }, p =
                    k,
                s = k;
            h.start = function () {
                j || f()
            };
            h.stop = function () {
                j && clearTimeout(j);
                j = b
            };
            a.browser.msie && !q && function () {
                var b, c;
                h.start = function () {
                    if (!b) c = (c = a.fn[e].src) && c + d(), b = a('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
                        c || p(d());
                        f()
                    }).attr("src", c || "javascript:0").insertAfter("body")[0].contentWindow, g.onpropertychange = function () {
                        try {
                            if (event.propertyName === "title") b.document.title = g.title
                        } catch (a) {}
                    }
                };
                h.stop = k;
                s = function () {
                    return d(b.location.href)
                };
                p = function (c, d) {
                    var f = b.document,
                        h = a.fn[e].domain;
                    if (c !== d) f.title = g.title, f.open(), h && f.write('<script>document.domain="' + h + '"<\/script>'), f.close(), b.location.hash = c
                }
            }();
            return h
        }()
    })(l, this);
    (function (a, c) {
        if (a.cleanData) {
            var b = a.cleanData;
            a.cleanData = function (e) {
                for (var c = 0, f;
                    (f = e[c]) != null; c++) a(f).triggerHandler("remove");
                b(e)
            }
        } else {
            var d = a.fn.remove;
            a.fn.remove = function (b, c) {
                return this.each(function () {
                    c || (!b || a.filter(b, [this]).length) && a("*", this).add([this]).each(function () {
                        a(this).triggerHandler("remove")
                    });
                    return d.call(a(this),
                        b, c)
                })
            }
        }
        a.widget = function (b, c, f) {
            var d = b.split(".")[0],
                h, b = b.split(".")[1];
            h = d + "-" + b;
            if (!f) f = c, c = a.Widget;
            a.expr[":"][h] = function (c) {
                return !!a.data(c, b)
            };
            a[d] = a[d] || {};
            a[d][b] = function (a, b) {
                arguments.length && this._createWidget(a, b)
            };
            c = new c;
            c.options = a.extend(true, {}, c.options);
            a[d][b].prototype = a.extend(true, c, {
                namespace: d,
                widgetName: b,
                widgetEventPrefix: a[d][b].prototype.widgetEventPrefix || b,
                widgetBaseClass: h
            }, f);
            a.widget.bridge(b, a[d][b])
        };
        a.widget.bridge = function (b, g) {
            a.fn[b] = function (d) {
                var j =
                    typeof d === "string",
                    h = Array.prototype.slice.call(arguments, 1),
                    q = this,
                    d = !j && h.length ? a.extend.apply(null, [true, d].concat(h)) : d;
                if (j && d.charAt(0) === "_") return q;
                j ? this.each(function () {
                    var g = a.data(this, b);
                    if (!g) throw "cannot call methods on " + b + " prior to initialization; attempted to call method '" + d + "'";
                    if (!a.isFunction(g[d])) throw "no such method '" + d + "' for " + b + " widget instance";
                    var j = g[d].apply(g, h);
                    if (j !== g && j !== c) return q = j, false
                }) : this.each(function () {
                    var c = a.data(this, b);
                    c ? c.option(d || {})._init() :
                        a.data(this, b, new g(d, this))
                });
                return q
            }
        };
        a.Widget = function (a, b) {
            arguments.length && this._createWidget(a, b)
        };
        a.Widget.prototype = {
            widgetName: "widget",
            widgetEventPrefix: "",
            options: {
                disabled: false
            },
            _createWidget: function (b, c) {
                a.data(c, this.widgetName, this);
                this.element = a(c);
                this.options = a.extend(true, {}, this.options, this._getCreateOptions(), b);
                var d = this;
                this.element.bind("remove." + this.widgetName, function () {
                    d.destroy()
                });
                this._create();
                this._trigger("create");
                this._init()
            },
            _getCreateOptions: function () {
                var b = {};
                a.metadata && (b = a.metadata.get(element)[this.widgetName]);
                return b
            },
            _create: function () {},
            _init: function () {},
            destroy: function () {
                this.element.unbind("." + this.widgetName).removeData(this.widgetName);
                this.widget().unbind("." + this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass + "-disabled ui-state-disabled")
            },
            widget: function () {
                return this.element
            },
            option: function (b, d) {
                var f = b;
                if (arguments.length === 0) return a.extend({}, this.options);
                if (typeof b === "string") {
                    if (d === c) return this.options[b];
                    f = {};
                    f[b] = d
                }
                this._setOptions(f);
                return this
            },
            _setOptions: function (b) {
                var c = this;
                a.each(b, function (a, b) {
                    c._setOption(a, b)
                });
                return this
            },
            _setOption: function (a, b) {
                this.options[a] = b;
                a === "disabled" && this.widget()[b ? "addClass" : "removeClass"](this.widgetBaseClass + "-disabled ui-state-disabled").attr("aria-disabled", b);
                return this
            },
            enable: function () {
                return this._setOption("disabled", false)
            },
            disable: function () {
                return this._setOption("disabled", true)
            },
            _trigger: function (b, c, d) {
                var j = this.options[b],
                    c = a.Event(c);
                c.type = (b === this.widgetEventPrefix ? b : this.widgetEventPrefix + b).toLowerCase();
                d = d || {};
                if (c.originalEvent)
                    for (var b = a.event.props.length, h; b;) h = a.event.props[--b], c[h] = c.originalEvent[h];
                this.element.trigger(c, d);
                return !(a.isFunction(j) && j.call(this.element[0], c, d) === false || c.isDefaultPrevented())
            }
        }
    })(l);
    (function (a, c) {
        a.widget("mobile.widget", {
            _createWidget: function () {
                a.Widget.prototype._createWidget.apply(this, arguments);
                this._trigger("init")
            },
            _getCreateOptions: function () {
                var b = this.element,
                    d = {};
                a.each(this.options, function (a) {
                    var g = b.jqmData(a.replace(/[A-Z]/g, function (a) {
                        return "-" + a.toLowerCase()
                    }));
                    g !== c && (d[a] = g)
                });
                return d
            },
            enhanceWithin: function (b, c) {
                this.enhance(a(this.options.initSelector, a(b)), c)
            },
            enhance: function (b, c) {
                var e, g = a(b),
                    g = a.mobile.enhanceable(g);
                c && g.length && (e = (e = a.mobile.closestPageData(g)) && e.keepNativeSelector() || "", g = g.not(e));
                g[this.widgetName]()
            },
            raise: function (a) {
                throw "Widget [" + this.widgetName + "]: " + a;
            }
        })
    })(l);
    (function (a, c) {
        var b = {};
        a.mobile = a.extend({}, {
            version: "1.1.1",
            ns: "",
            subPageUrlKey: "ui-page",
            activePageClass: "ui-page-active",
            activeBtnClass: "ui-btn-active",
            focusClass: "ui-focus",
            ajaxEnabled: true,
            hashListeningEnabled: true,
            linkBindingEnabled: true,
            defaultPageTransition: "fade",
            maxTransitionWidth: false,
            minScrollBack: 250,
            touchOverflowEnabled: false,
            defaultDialogTransition: "pop",
            loadingMessage: "loading",
            pageLoadErrorMessage: "Error Loading Page",
            loadingMessageTextVisible: false,
            loadingMessageTheme: "a",
            pageLoadErrorMessageTheme: "e",
            autoInitializePage: true,
            pushStateEnabled: true,
            ignoreContentEnabled: false,
            orientationChangeEnabled: true,
            buttonMarkup: {
                hoverDelay: 200
            },
            keyCode: {
                ALT: 18,
                BACKSPACE: 8,
                CAPS_LOCK: 20,
                COMMA: 188,
                COMMAND: 91,
                COMMAND_LEFT: 91,
                COMMAND_RIGHT: 93,
                CONTROL: 17,
                DELETE: 46,
                DOWN: 40,
                END: 35,
                ENTER: 13,
                ESCAPE: 27,
                HOME: 36,
                INSERT: 45,
                LEFT: 37,
                MENU: 93,
                NUMPAD_ADD: 107,
                NUMPAD_DECIMAL: 110,
                NUMPAD_DIVIDE: 111,
                NUMPAD_ENTER: 108,
                NUMPAD_MULTIPLY: 106,
                NUMPAD_SUBTRACT: 109,
                PAGE_DOWN: 34,
                PAGE_UP: 33,
                PERIOD: 190,
                RIGHT: 39,
                SHIFT: 16,
                SPACE: 32,
                TAB: 9,
                UP: 38,
                WINDOWS: 91
            },
            silentScroll: function (b) {
                if (a.type(b) !==
                    "number") b = a.mobile.defaultHomeScroll;
                a.event.special.scrollstart.enabled = false;
                setTimeout(function () {
                    c.scrollTo(0, b);
                    a(k).trigger("silentscroll", {
                        x: 0,
                        y: b
                    })
                }, 20);
                setTimeout(function () {
                    a.event.special.scrollstart.enabled = true
                }, 150)
            },
            nsNormalizeDict: b,
            nsNormalize: function (c) {
                return !c ? void 0 : b[c] || (b[c] = a.camelCase(a.mobile.ns + c))
            },
            getInheritedTheme: function (a, b) {
                for (var c = a[0], d = "", e = /ui-(bar|body|overlay)-([a-z])\b/, o, m; c;) {
                    if ((o = c.className || "") && (m = e.exec(o)) && (d = m[2])) break;
                    c = c.parentNode
                }
                return d ||
                    b || "a"
            },
            closestPageData: function (a) {
                return a.closest(':jqmData(role="page"), :jqmData(role="dialog")').data("page")
            },
            enhanceable: function (a) {
                return this.haveParents(a, "enhance")
            },
            hijackable: function (a) {
                return this.haveParents(a, "ajax")
            },
            haveParents: function (b, c) {
                if (!a.mobile.ignoreContentEnabled) return b;
                for (var d = b.length, e = a(), q, o, m, v = 0; v < d; v++) {
                    o = b.eq(v);
                    m = false;
                    for (q = b[v]; q;) {
                        if ((q.getAttribute ? q.getAttribute("data-" + a.mobile.ns + c) : "") === "false") {
                            m = true;
                            break
                        }
                        q = q.parentNode
                    }
                    m || (e = e.add(o))
                }
                return e
            },
            getScreenHeight: function () {
                return c.innerHeight || a(c).height()
            }
        }, a.mobile);
        a.fn.jqmData = function (b, c) {
            var d;
            typeof b != "undefined" && (b && (b = a.mobile.nsNormalize(b)), d = this.data.apply(this, arguments.length < 2 ? [b] : [b, c]));
            return d
        };
        a.jqmData = function (b, c, d) {
            var e;
            typeof c != "undefined" && (e = a.data(b, c ? a.mobile.nsNormalize(c) : c, d));
            return e
        };
        a.fn.jqmRemoveData = function (b) {
            return this.removeData(a.mobile.nsNormalize(b))
        };
        a.jqmRemoveData = function (b, c) {
            return a.removeData(b, a.mobile.nsNormalize(c))
        };
        a.fn.removeWithDependents =
            function () {
                a.removeWithDependents(this)
        };
        a.removeWithDependents = function (b) {
            b = a(b);
            (b.jqmData("dependents") || a()).remove();
            b.remove()
        };
        a.fn.addDependents = function (b) {
            a.addDependents(a(this), b)
        };
        a.addDependents = function (b, c) {
            var d = a(b).jqmData("dependents") || a();
            a(b).jqmData("dependents", a.merge(d, c))
        };
        a.fn.getEncodedText = function () {
            return a("<div/>").text(a(this).text()).html()
        };
        a.fn.jqmEnhanceable = function () {
            return a.mobile.enhanceable(this)
        };
        a.fn.jqmHijackable = function () {
            return a.mobile.hijackable(this)
        };
        var d = a.find,
            e = /:jqmData\(([^)]*)\)/g;
        a.find = function (b, c, j, h) {
            b = b.replace(e, "[data-" + (a.mobile.ns || "") + "$1]");
            return d.call(this, b, c, j, h)
        };
        a.extend(a.find, d);
        a.find.matches = function (b, c) {
            return a.find(b, null, null, c)
        };
        a.find.matchesSelector = function (b, c) {
            return a.find(c, null, null, [b]).length > 0
        }
    })(l, this);
    (function (a) {
        a(t);
        var c = a("html");
        a.mobile.media = function () {
            var b = {}, d = a("<div id='jquery-mediatest'></div>"),
                e = a("<body>").append(d);
            return function (a) {
                if (!(a in b)) {
                    var f = k.createElement("style"),
                        j = "@media " + a + " { #jquery-mediatest { position:absolute; } }";
                    f.type = "text/css";
                    f.styleSheet ? f.styleSheet.cssText = j : f.appendChild(k.createTextNode(j));
                    c.prepend(e).prepend(f);
                    b[a] = d.css("position") === "absolute";
                    e.add(f).remove()
                }
                return b[a]
            }
        }()
    })(l);
    (function (a, c) {
        function b(a) {
            var b = a.charAt(0).toUpperCase() + a.substr(1),
                a = (a + " " + f.join(b + " ") + b).split(" "),
                d;
            for (d in a)
                if (g[a[d]] !== c) return true
        }

        function d(a, b, c) {
            var d = k.createElement("div"),
                c = c ? [c] : f,
                e;
            for (i = 0; i < c.length; i++) {
                var h = c[i],
                    j = "-" + h.charAt(0).toLowerCase() +
                        h.substr(1) + "-" + a + ": " + b + ";",
                    h = h.charAt(0).toUpperCase() + h.substr(1) + (a.charAt(0).toUpperCase() + a.substr(1));
                d.setAttribute("style", j);
                d.style[h] && (e = true)
            }
            return !!e
        }
        var e = a("<body>").prependTo("html"),
            g = e[0].style,
            f = ["Webkit", "Moz", "O"],
            j = "palmGetResource" in t,
            h = t.opera,
            q = t.operamini && {}.toString.call(t.operamini) === "[object OperaMini]",
            o = t.blackberry;
        a.extend(a.mobile, {
            browser: {}
        });
        a.mobile.browser.ie = function () {
            for (var a = 3, b = k.createElement("div"), c = b.all || []; b.innerHTML = "<\!--[if gt IE " + ++a +
                "]><br><![endif]--\>", c[0];);
            return a > 4 ? a : !a
        }();
        a.extend(a.support, {
            orientation: "orientation" in t && "onorientationchange" in t,
            touch: "ontouchend" in k,
            cssTransitions: "WebKitTransitionEvent" in t || d("transition", "height 100ms linear") && !h,
            pushState: "pushState" in history && "replaceState" in history,
            mediaquery: a.mobile.media("only all"),
            cssPseudoElement: !! b("content"),
            touchOverflow: !! b("overflowScrolling"),
            cssTransform3d: d("perspective", "10px", "moz") || a.mobile.media("(-" + f.join("-transform-3d),(-") + "-transform-3d),(transform-3d)"),
            boxShadow: !! b("boxShadow") && !o,
            scrollTop: ("pageXOffset" in t || "scrollTop" in k.documentElement || "scrollTop" in e[0]) && !j && !q,
            dynamicBaseTag: function () {
                var b = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
                    c = a("head base"),
                    d = null,
                    h = "",
                    f;
                c.length ? h = c.attr("href") : c = d = a("<base>", {
                    href: b
                }).appendTo("head");
                f = a("<a href='testurl' />").prependTo(e)[0].href;
                c[0].href = h || location.pathname;
                d && d.remove();
                return f.indexOf(b) === 0
            }(),
            cssPointerEvents: function () {
                var a = k.createElement("x"),
                    b = k.documentElement,
                    c = t.getComputedStyle;
                if (!("pointerEvents" in a.style)) return false;
                a.style.pointerEvents = "auto";
                a.style.pointerEvents = "x";
                b.appendChild(a);
                c = c && c(a, "").pointerEvents === "auto";
                b.removeChild(a);
                return !!c
            }()
        });
        e.remove();
        j = function () {
            var a = t.navigator.userAgent;
            return a.indexOf("Nokia") > -1 && (a.indexOf("Symbian/3") > -1 || a.indexOf("Series60/5") > -1) && a.indexOf("AppleWebKit") > -1 && a.match(/(BrowserNG|NokiaBrowser)\/7\.[0-3]/)
        }();
        a.mobile.gradeA = function () {
            return a.support.mediaquery || a.mobile.browser.ie && a.mobile.browser.ie >=
                7
        };
        a.mobile.ajaxBlacklist = t.blackberry && !t.WebKitPoint || q || j;
        j && a(function () {
            a("head link[rel='stylesheet']").attr("rel", "alternate stylesheet").attr("rel", "stylesheet")
        });
        a.support.boxShadow || a("html").addClass("ui-mobile-nosupport-boxshadow")
    })(l);
    (function (a, c, b) {
        function d(b, c, d) {
            var e = d.type;
            d.type = c;
            a.event.handle.call(b, d);
            d.type = e
        }
        a.each("touchstart touchmove touchend orientationchange throttledresize tap taphold swipe swipeleft swiperight scrollstart scrollstop".split(" "), function (b, c) {
            a.fn[c] =
                function (a) {
                    return a ? this.bind(c, a) : this.trigger(c)
            };
            a.attrFn[c] = true
        });
        var e = a.support.touch,
            g = e ? "touchstart" : "mousedown",
            f = e ? "touchend" : "mouseup",
            j = e ? "touchmove" : "mousemove";
        a.event.special.scrollstart = {
            enabled: true,
            setup: function () {
                function b(a, h) {
                    e = h;
                    d(c, e ? "scrollstart" : "scrollstop", a)
                }
                var c = this,
                    e, f;
                a(c).bind("touchmove scroll", function (c) {
                    a.event.special.scrollstart.enabled && (e || b(c, true), clearTimeout(f), f = setTimeout(function () {
                        b(c, false)
                    }, 50))
                })
            }
        };
        a.event.special.tap = {
            setup: function () {
                var b =
                    this,
                    c = a(b);
                c.bind("vmousedown", function (e) {
                    function f() {
                        clearTimeout(p)
                    }

                    function j() {
                        f();
                        c.unbind("vclick", g).unbind("vmouseup", f);
                        a(k).unbind("vmousecancel", j)
                    }

                    function g(a) {
                        j();
                        r == a.target && d(b, "tap", a)
                    }
                    if (e.which && e.which !== 1) return false;
                    var r = e.target,
                        p;
                    c.bind("vmouseup", f).bind("vclick", g);
                    a(k).bind("vmousecancel", j);
                    p = setTimeout(function () {
                        d(b, "taphold", a.Event("taphold", {
                            target: r
                        }))
                    }, 750)
                })
            }
        };
        a.event.special.swipe = {
            scrollSupressionThreshold: 10,
            durationThreshold: 1E3,
            horizontalDistanceThreshold: 30,
            verticalDistanceThreshold: 75,
            setup: function () {
                var c = a(this);
                c.bind(g, function (d) {
                    function e(b) {
                        if (k) {
                            var c = b.originalEvent.touches ? b.originalEvent.touches[0] : b;
                            n = {
                                time: (new Date).getTime(),
                                coords: [c.pageX, c.pageY]
                            };
                            Math.abs(k.coords[0] - n.coords[0]) > a.event.special.swipe.scrollSupressionThreshold && b.preventDefault()
                        }
                    }
                    var g = d.originalEvent.touches ? d.originalEvent.touches[0] : d,
                        k = {
                            time: (new Date).getTime(),
                            coords: [g.pageX, g.pageY],
                            origin: a(d.target)
                        }, n;
                    c.bind(j, e).one(f, function () {
                        c.unbind(j, e);
                        k && n &&
                            n.time - k.time < a.event.special.swipe.durationThreshold && Math.abs(k.coords[0] - n.coords[0]) > a.event.special.swipe.horizontalDistanceThreshold && Math.abs(k.coords[1] - n.coords[1]) < a.event.special.swipe.verticalDistanceThreshold && k.origin.trigger("swipe").trigger(k.coords[0] > n.coords[0] ? "swipeleft" : "swiperight");
                        k = n = b
                    })
                })
            }
        };
        (function (a, b) {
            function c() {
                var a = e();
                a !== f && (f = a, d.trigger("orientationchange"))
            }
            var d = a(b),
                e, f, j, g, l = {
                    0: true,
                    180: true
                };
            if (a.support.orientation && (j = b.innerWidth || a(b).width(), g = b.innerHeight ||
                a(b).height(), j = j > g && j - g > 50, g = l[b.orientation], j && g || !j && !g)) l = {
                "-90": true,
                90: true
            };
            a.event.special.orientationchange = {
                setup: function () {
                    if (a.support.orientation && a.mobile.orientationChangeEnabled) return false;
                    f = e();
                    d.bind("throttledresize", c)
                },
                teardown: function () {
                    if (a.support.orientation && a.mobile.orientationChangeEnabled) return false;
                    d.unbind("throttledresize", c)
                },
                add: function (a) {
                    var b = a.handler;
                    a.handler = function (a) {
                        a.orientation = e();
                        return b.apply(this, arguments)
                    }
                }
            };
            a.event.special.orientationchange.orientation =
                e = function () {
                    var c = true,
                        c = k.documentElement;
                    return (c = a.support.orientation ? l[b.orientation] : c && c.clientWidth / c.clientHeight < 1.1) ? "portrait" : "landscape"
            }
        })(l, c);
        (function () {
            a.event.special.throttledresize = {
                setup: function () {
                    a(this).bind("resize", b)
                },
                teardown: function () {
                    a(this).unbind("resize", b)
                }
            };
            var b = function () {
                e = (new Date).getTime();
                f = e - c;
                f >= 250 ? (c = e, a(this).trigger("throttledresize")) : (d && clearTimeout(d), d = setTimeout(b, 250 - f))
            }, c = 0,
                d, e, f
        })();
        a.each({
            scrollstop: "scrollstart",
            taphold: "tap",
            swipeleft: "swipe",
            swiperight: "swipe"
        }, function (b, c) {
            a.event.special[b] = {
                setup: function () {
                    a(this).bind(c, a.noop)
                }
            }
        })
    })(l, this);
    (function (a) {
        a.widget("mobile.page", a.mobile.widget, {
            options: {
                theme: "c",
                domCache: false,
                keepNativeDefault: ":jqmData(role='none'), :jqmData(role='nojs')"
            },
            _create: function () {
                var a = this;
                if (a._trigger("beforecreate") === false) return false;
                a.element.attr("tabindex", "0").addClass("ui-page ui-body-" + a.options.theme).bind("pagebeforehide", function () {
                    a.removeContainerBackground()
                }).bind("pagebeforeshow",
                    function () {
                        a.setContainerBackground()
                    })
            },
            removeContainerBackground: function () {
                a.mobile.pageContainer.removeClass("ui-overlay-" + a.mobile.getInheritedTheme(this.element.parent()))
            },
            setContainerBackground: function (c) {
                this.options.theme && a.mobile.pageContainer.addClass("ui-overlay-" + (c || this.options.theme))
            },
            keepNativeSelector: function () {
                var c = this.options;
                return c.keepNative && a.trim(c.keepNative) && c.keepNative !== c.keepNativeDefault ? [c.keepNative, c.keepNativeDefault].join(", ") : c.keepNativeDefault
            }
        })
    })(l);
    (function (a, c, b) {
        var d = function (d) {
            d === b && (d = true);
            return function (b, e, h, q) {
                var k = new a.Deferred,
                    m = e ? " reverse" : "",
                    l = a.mobile.urlHistory.getActive().lastScroll || a.mobile.defaultHomeScroll,
                    n = a.mobile.getScreenHeight(),
                    r = a.mobile.maxTransitionWidth !== false && a(c).width() > a.mobile.maxTransitionWidth,
                    p = !a.support.cssTransitions || r || !b || b === "none" || Math.max(a(c).scrollTop(), l) > a.mobile.getMaxScrollForTransition(),
                    s = function () {
                        a.mobile.pageContainer.toggleClass("ui-mobile-viewport-transitioning viewport-" +
                            b)
                    }, u = function () {
                        a.event.special.scrollstart.enabled = false;
                        c.scrollTo(0, l);
                        setTimeout(function () {
                            a.event.special.scrollstart.enabled = true
                        }, 150)
                    }, x = function () {
                        q.removeClass(a.mobile.activePageClass + " out in reverse " + b).height("")
                    }, r = function () {
                        q && d && x();
                        h.addClass(a.mobile.activePageClass);
                        a.mobile.focusPage(h);
                        h.height(n + l);
                        u();
                        p || h.animationComplete(w);
                        h.addClass(b + " in" + m);
                        p && w()
                    }, w = function () {
                        d || q && x();
                        h.removeClass("out in reverse " + b).height("");
                        s();
                        a(c).scrollTop() !== l && u();
                        k.resolve(b, e, h,
                            q, true)
                    };
                s();
                q && !p ? (d ? q.animationComplete(r) : r(), q.height(n + a(c).scrollTop()).addClass(b + " out" + m)) : r();
                return k.promise()
            }
        }, e = d(),
            d = d(false);
        a.mobile.defaultTransitionHandler = e;
        a.mobile.transitionHandlers = {
            "default": a.mobile.defaultTransitionHandler,
            sequential: e,
            simultaneous: d
        };
        a.mobile.transitionFallbacks = {};
        a.mobile.getMaxScrollForTransition = a.mobile.getMaxScrollForTransition || function () {
            return a.mobile.getScreenHeight() * 3
        }
    })(l, this);
    (function (a, c) {
        function b(b) {
            l && (!l.closest(".ui-page-active").length ||
                b) && l.removeClass(a.mobile.activeBtnClass);
            l = null
        }

        function d() {
            p = false;
            r.length > 0 && a.mobile.changePage.apply(null, r.pop())
        }

        function e(b, c, d, e) {
            c && c.data("page")._trigger("beforehide", null, {
                nextPage: b
            });
            b.data("page")._trigger("beforeshow", null, {
                prevPage: c || a("")
            });
            a.mobile.hidePageLoadingMsg();
            d && !a.support.cssTransform3d && a.mobile.transitionFallbacks[d] && (d = a.mobile.transitionFallbacks[d]);
            d = (a.mobile.transitionHandlers[d || "default"] || a.mobile.defaultTransitionHandler)(d, e, b, c);
            d.done(function () {
                c &&
                    c.data("page")._trigger("hide", null, {
                        nextPage: b
                    });
                b.data("page")._trigger("show", null, {
                    prevPage: c || a("")
                })
            });
            return d
        }

        function g() {
            var b = a("." + a.mobile.activePageClass),
                c = parseFloat(b.css("padding-top")),
                d = parseFloat(b.css("padding-bottom")),
                e = parseFloat(b.css("border-top-width")),
                f = parseFloat(b.css("border-bottom-width"));
            b.css("min-height", y() - c - d - e - f)
        }

        function f(b, c) {
            c && b.attr("data-" + a.mobile.ns + "role", c);
            b.page()
        }

        function j(a) {
            for (; a;) {
                if (typeof a.nodeName === "string" && a.nodeName.toLowerCase() ==
                    "a") break;
                a = a.parentNode
            }
            return a
        }

        function h(b) {
            var b = a(b).closest(".ui-page").jqmData("url"),
                c = w.hrefNoHash;
            if (!b || !m.isPath(b)) b = c;
            return m.makeUrlAbsolute(b, c)
        }
        var q = a(t);
        a("html");
        var o = a("head"),
            m = {
                urlParseRE: /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/,
                parseUrl: function (b) {
                    if (a.type(b) === "object") return b;
                    b = m.urlParseRE.exec(b || "") || [];
                    return {
                        href: b[0] || "",
                        hrefNoHash: b[1] ||
                            "",
                        hrefNoSearch: b[2] || "",
                        domain: b[3] || "",
                        protocol: b[4] || "",
                        doubleSlash: b[5] || "",
                        authority: b[6] || "",
                        username: b[8] || "",
                        password: b[9] || "",
                        host: b[10] || "",
                        hostname: b[11] || "",
                        port: b[12] || "",
                        pathname: b[13] || "",
                        directory: b[14] || "",
                        filename: b[15] || "",
                        search: b[16] || "",
                        hash: b[17] || ""
                    }
                },
                makePathAbsolute: function (a, b) {
                    if (a && a.charAt(0) === "/") return a;
                    for (var a = a || "", c = (b = b ? b.replace(/^\/|(\/[^\/]*|[^\/]+)$/g, "") : "") ? b.split("/") : [], d = a.split("/"), e = 0; e < d.length; e++) {
                        var f = d[e];
                        switch (f) {
                        case ".":
                            break;
                        case "..":
                            c.length &&
                                c.pop();
                            break;
                        default:
                            c.push(f)
                        }
                    }
                    return "/" + c.join("/")
                },
                isSameDomain: function (a, b) {
                    return m.parseUrl(a).domain === m.parseUrl(b).domain
                },
                isRelativeUrl: function (a) {
                    return m.parseUrl(a).protocol === ""
                },
                isAbsoluteUrl: function (a) {
                    return m.parseUrl(a).protocol !== ""
                },
                makeUrlAbsolute: function (a, b) {
                    if (!m.isRelativeUrl(a)) return a;
                    var c = m.parseUrl(a),
                        d = m.parseUrl(b),
                        e = c.protocol || d.protocol,
                        f = c.protocol ? c.doubleSlash : c.doubleSlash || d.doubleSlash,
                        h = c.authority || d.authority,
                        j = c.pathname !== "",
                        g = m.makePathAbsolute(c.pathname ||
                            d.filename, d.pathname);
                    return e + f + h + g + (c.search || !j && d.search || "") + c.hash
                },
                addSearchParams: function (b, c) {
                    var d = m.parseUrl(b),
                        e = typeof c === "object" ? a.param(c) : c,
                        f = d.search || "?";
                    return d.hrefNoSearch + f + (f.charAt(f.length - 1) !== "?" ? "&" : "") + e + (d.hash || "")
                },
                convertUrlToDataUrl: function (a) {
                    var b = m.parseUrl(a);
                    if (m.isEmbeddedPage(b)) return b.hash.split(s)[0].replace(/^#/, "");
                    else if (m.isSameDomain(b, w)) return b.hrefNoHash.replace(w.domain, "").split(s)[0];
                    return a
                },
                get: function (a) {
                    if (a === c) a = location.hash;
                    return m.stripHash(a).replace(/[^\/]*\.[^\/*]+$/, "")
                },
                getFilePath: function (b) {
                    var c = "&" + a.mobile.subPageUrlKey;
                    return b && b.split(c)[0].split(s)[0]
                },
                set: function (a) {
                    location.hash = a
                },
                isPath: function (a) {
                    return /\//.test(a)
                },
                clean: function (a) {
                    return a.replace(w.domain, "")
                },
                stripHash: function (a) {
                    return a.replace(/^#/, "")
                },
                cleanHash: function (a) {
                    return m.stripHash(a.replace(/\?.*$/, "").replace(s, ""))
                },
                isHashValid: function (a) {
                    return /^#[^#]+$/.test(a)
                },
                isExternal: function (a) {
                    a = m.parseUrl(a);
                    return a.protocol &&
                        a.domain !== x.domain ? true : false
                },
                hasProtocol: function (a) {
                    return /^(:?\w+:)/.test(a)
                },
                isFirstPageUrl: function (b) {
                    var b = m.parseUrl(m.makeUrlAbsolute(b, w)),
                        d = a.mobile.firstPage,
                        d = d && d[0] ? d[0].id : c;
                    return (b.hrefNoHash === x.hrefNoHash || D && b.hrefNoHash === w.hrefNoHash) && (!b.hash || b.hash === "#" || d && b.hash.replace(/^#/, "") === d)
                },
                isEmbeddedPage: function (a) {
                    a = m.parseUrl(a);
                    return a.protocol !== "" ? a.hash && (a.hrefNoHash === x.hrefNoHash || D && a.hrefNoHash === w.hrefNoHash) : /^#/.test(a.href)
                },
                isPermittedCrossDomainRequest: function (b,
                    c) {
                    return a.mobile.allowCrossDomainPages && b.protocol === "file:" && c.search(/^https?:/) != -1
                }
            }, l = null,
            n = {
                stack: [],
                activeIndex: 0,
                getActive: function () {
                    return n.stack[n.activeIndex]
                },
                getPrev: function () {
                    return n.stack[n.activeIndex - 1]
                },
                getNext: function () {
                    return n.stack[n.activeIndex + 1]
                },
                addNew: function (a, b, c, d, e) {
                    n.getNext() && n.clearForward();
                    n.stack.push({
                        url: a,
                        transition: b,
                        title: c,
                        pageUrl: d,
                        role: e
                    });
                    n.activeIndex = n.stack.length - 1
                },
                clearForward: function () {
                    n.stack = n.stack.slice(0, n.activeIndex + 1)
                },
                directHashChange: function (b) {
                    var d,
                        e, f;
                    this.getActive();
                    a.each(n.stack, function (a, c) {
                        b.currentUrl === c.url && (d = a < n.activeIndex, e = !d, f = a)
                    });
                    this.activeIndex = f !== c ? f : this.activeIndex;
                    d ? (b.either || b.isBack)(true) : e && (b.either || b.isForward)(false)
                },
                ignoreNextHashChange: false
            }, r = [],
            p = false,
            s = "&ui-state=dialog",
            u = o.children("base"),
            x = m.parseUrl(location.href),
            w = u.length ? m.parseUrl(m.makeUrlAbsolute(u.attr("href"), x.href)) : x,
            D = x.hrefNoHash !== w.hrefNoHash,
            y = a.mobile.getScreenHeight,
            B = a.support.dynamicBaseTag ? {
                element: u.length ? u : a("<base>", {
                    href: w.hrefNoHash
                }).prependTo(o),
                set: function (a) {
                    B.element.attr("href", m.makeUrlAbsolute(a, w))
                },
                reset: function () {
                    B.element.attr("href", w.hrefNoHash)
                }
            } : c;
        a.mobile.focusPage = function (a) {
            var b = a.find("[autofocus]"),
                c = a.find(".ui-title:eq(0)");
            b.length ? b.focus() : c.length ? c.focus() : a.focus()
        };
        var C = true,
            z, A;
        z = function () {
            if (C) {
                var b = a.mobile.urlHistory.getActive();
                if (b) {
                    var c = q.scrollTop();
                    b.lastScroll = c < a.mobile.minScrollBack ? a.mobile.defaultHomeScroll : c
                }
            }
        };
        A = function () {
            setTimeout(z, 100)
        };
        q.bind(a.support.pushState ?
            "popstate" : "hashchange", function () {
                C = false
            });
        q.one(a.support.pushState ? "popstate" : "hashchange", function () {
            C = true
        });
        q.one("pagecontainercreate", function () {
            a.mobile.pageContainer.bind("pagechange", function () {
                C = true;
                q.unbind("scrollstop", A);
                q.bind("scrollstop", A)
            })
        });
        q.bind("scrollstop", A);
        a.fn.animationComplete = function (b) {
            return a.support.cssTransitions ? a(this).one("webkitAnimationEnd animationend", b) : (setTimeout(b, 0), a(this))
        };
        a.mobile.path = m;
        a.mobile.base = B;
        a.mobile.urlHistory = n;
        a.mobile.dialogHashKey =
            s;
        a.mobile.allowCrossDomainPages = false;
        a.mobile.getDocumentUrl = function (b) {
            return b ? a.extend({}, x) : x.href
        };
        a.mobile.getDocumentBase = function (b) {
            return b ? a.extend({}, w) : w.href
        };
        a.mobile._bindPageRemove = function () {
            var b = a(this);
            !b.data("page").options.domCache && b.is(":jqmData(external-page='true')") && b.bind("pagehide.remove", function () {
                var b = a(this),
                    c = new a.Event("pageremove");
                b.trigger(c);
                c.isDefaultPrevented() || b.removeWithDependents()
            })
        };
        a.mobile.loadPage = function (b, d) {
            var e = a.Deferred(),
                j = a.extend({},
                    a.mobile.loadPage.defaults, d),
                g = null,
                q = null,
                k = m.makeUrlAbsolute(b, a.mobile.activePage && h(a.mobile.activePage) || w.hrefNoHash);
            if (j.data && j.type === "get") k = m.addSearchParams(k, j.data), j.data = c;
            if (j.data && j.type === "post") j.reloadPage = true;
            var n = m.getFilePath(k),
                o = m.convertUrlToDataUrl(k);
            j.pageContainer = j.pageContainer || a.mobile.pageContainer;
            g = j.pageContainer.children(":jqmData(url='" + o + "')");
            g.length === 0 && o && !m.isPath(o) && (g = j.pageContainer.children("#" + o).attr("data-" + a.mobile.ns + "url", o));
            if (g.length ===
                0)
                if (a.mobile.firstPage && m.isFirstPageUrl(n)) a.mobile.firstPage.parent().length && (g = a(a.mobile.firstPage));
                else if (m.isEmbeddedPage(n)) return e.reject(k, d), e.promise();
            B && B.reset();
            if (g.length) {
                if (!j.reloadPage) return f(g, j.role), e.resolve(k, d, g), e.promise();
                q = g
            }
            var l = j.pageContainer,
                u = new a.Event("pagebeforeload"),
                p = {
                    url: b,
                    absUrl: k,
                    dataUrl: o,
                    deferred: e,
                    options: j
                };
            l.trigger(u, p);
            if (u.isDefaultPrevented()) return e.promise();
            if (j.showLoadMsg) var r = setTimeout(function () {
                    a.mobile.showPageLoadingMsg()
                },
                j.loadMsgDelay);
            !a.mobile.allowCrossDomainPages && !m.isSameDomain(x, k) ? e.reject(k, d) : a.ajax({
                url: n,
                type: j.type,
                data: j.data,
                dataType: "html",
                success: function (c, h, x) {
                    var l = a("<div></div>"),
                        u = c.match(/<title[^>]*>([^<]*)/) && RegExp.$1,
                        w = RegExp("\\bdata-" + a.mobile.ns + "url=[\"']?([^\"'>]*)[\"']?");
                    RegExp("(<[^>]+\\bdata-" + a.mobile.ns + "role=[\"']?page[\"']?[^>]*>)").test(c) && RegExp.$1 && w.test(RegExp.$1) && RegExp.$1 && (b = n = m.getFilePath(RegExp.$1));
                    B && B.set(n);
                    l.get(0).innerHTML = c;
                    g = l.find(":jqmData(role='page'), :jqmData(role='dialog')").first();
                    g.length || (g = a("<div data-" + a.mobile.ns + "role='page'>" + c.split(/<\/?body[^>]*>/gmi)[1] + "</div>"));
                    u && !g.jqmData("title") && (~u.indexOf("&") && (u = a("<div>" + u + "</div>").text()), g.jqmData("title", u));
                    if (!a.support.dynamicBaseTag) {
                        var s = m.get(n);
                        g.find("[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]").each(function () {
                            var b = a(this).is("[href]") ? "href" : a(this).is("[src]") ? "src" : "action",
                                c = a(this).attr(b),
                                c = c.replace(location.protocol + "//" + location.host + location.pathname, "");
                            /^(\w+:|#|\/)/.test(c) ||
                                a(this).attr(b, s + c)
                        })
                    }
                    g.attr("data-" + a.mobile.ns + "url", m.convertUrlToDataUrl(n)).attr("data-" + a.mobile.ns + "external-page", true).appendTo(j.pageContainer);
                    g.one("pagecreate", a.mobile._bindPageRemove);
                    f(g, j.role);
                    k.indexOf("&" + a.mobile.subPageUrlKey) > -1 && (g = j.pageContainer.children(":jqmData(url='" + o + "')"));
                    j.showLoadMsg && (clearTimeout(r), a.mobile.hidePageLoadingMsg());
                    p.xhr = x;
                    p.textStatus = h;
                    p.page = g;
                    j.pageContainer.trigger("pageload", p);
                    e.resolve(k, d, g, q)
                },
                error: function (b, c, f) {
                    B && B.set(m.get());
                    p.xhr =
                        b;
                    p.textStatus = c;
                    p.errorThrown = f;
                    b = new a.Event("pageloadfailed");
                    j.pageContainer.trigger(b, p);
                    b.isDefaultPrevented() || (j.showLoadMsg && (clearTimeout(r), a.mobile.hidePageLoadingMsg(), a.mobile.showPageLoadingMsg(a.mobile.pageLoadErrorMessageTheme, a.mobile.pageLoadErrorMessage, true), setTimeout(a.mobile.hidePageLoadingMsg, 1500)), e.reject(k, d))
                }
            });
            return e.promise()
        };
        a.mobile.loadPage.defaults = {
            type: "get",
            data: c,
            reloadPage: false,
            role: c,
            showLoadMsg: false,
            pageContainer: c,
            loadMsgDelay: 50
        };
        a.mobile.changePage =
            function (j, g) {
                if (p) r.unshift(arguments);
                else {
                    var h = a.extend({}, a.mobile.changePage.defaults, g);
                    h.pageContainer = h.pageContainer || a.mobile.pageContainer;
                    h.fromPage = h.fromPage || a.mobile.activePage;
                    var q = h.pageContainer,
                        o = new a.Event("pagebeforechange"),
                        l = {
                            toPage: j,
                            options: h
                        };
                    q.trigger(o, l);
                    if (!o.isDefaultPrevented())
                        if (j = l.toPage, p = true, typeof j == "string") a.mobile.loadPage(j, h).done(function (b, c, d, e) {
                            p = false;
                            c.duplicateCachedPage = e;
                            a.mobile.changePage(d, c)
                        }).fail(function () {
                            p = false;
                            b(true);
                            d();
                            h.pageContainer.trigger("pagechangefailed",
                                l)
                        });
                        else {
                            if (j[0] === a.mobile.firstPage[0] && !h.dataUrl) h.dataUrl = x.hrefNoHash;
                            var o = h.fromPage,
                                u = h.dataUrl && m.convertUrlToDataUrl(h.dataUrl) || j.jqmData("url"),
                                w = u;
                            m.getFilePath(u);
                            var v = n.getActive(),
                                t = n.activeIndex === 0,
                                y = 0,
                                D = k.title,
                                B = h.role === "dialog" || j.jqmData("role") === "dialog";
                            if (o && o[0] === j[0] && !h.allowSamePageTransition) p = false, q.trigger("pagechange", l), h.fromHashChange && n.directHashChange({
                                currentUrl: u,
                                isBack: function () {},
                                isForward: function () {}
                            });
                            else {
                                f(j, h.role);
                                h.fromHashChange && n.directHashChange({
                                    currentUrl: u,
                                    isBack: function () {
                                        y = -1
                                    },
                                    isForward: function () {
                                        y = 1
                                    }
                                });
                                try {
                                    k.activeElement && k.activeElement.nodeName.toLowerCase() != "body" ? a(k.activeElement).blur() : a("input:focus, textarea:focus, select:focus").blur()
                                } catch (z) {}
                                var C = false;
                                if (B && v) {
                                    if (v.url.indexOf(s) > -1 && !a.mobile.activePage.is(".ui-dialog")) h.changeHash = false, C = true;
                                    u = (v.url || "") + s;
                                    n.activeIndex === 0 && u === n.initialDst && (u += s)
                                }
                                if (h.changeHash !== false && u) n.ignoreNextHashChange = true, m.set(u);
                                var A = !v ? D : j.jqmData("title") || j.children(":jqmData(role='header')").find(".ui-title").getEncodedText();
                                A && D == k.title && (D = A);
                                j.jqmData("title") || j.jqmData("title", D);
                                h.transition = h.transition || (y && !t ? v.transition : c) || (B ? a.mobile.defaultDialogTransition : a.mobile.defaultPageTransition);
                                !y && !C && n.addNew(u, h.transition, D, w, h.role);
                                k.title = n.getActive().title;
                                a.mobile.activePage = j;
                                h.reverse = h.reverse || y < 0;
                                e(j, o, h.transition, h.reverse).done(function (c, e, f, g, m) {
                                    b();
                                    h.duplicateCachedPage && h.duplicateCachedPage.remove();
                                    m || a.mobile.focusPage(j);
                                    d();
                                    q.trigger("pagechange", l)
                                })
                            }
                        }
                }
        };
        a.mobile.changePage.defaults = {
            transition: c,
            reverse: false,
            changeHash: true,
            fromHashChange: false,
            role: c,
            duplicateCachedPage: c,
            pageContainer: c,
            showLoadMsg: true,
            dataUrl: c,
            fromPage: c,
            allowSamePageTransition: false
        };
        a.mobile.navreadyDeferred = a.Deferred();
        a.mobile.navreadyDeferred.done(function () {
            a(k).delegate("form", "submit", function (b) {
                var c = a(this);
                if (a.mobile.ajaxEnabled && !c.is(":jqmData(ajax='false')") && c.jqmHijackable().length) {
                    var d = c.attr("method"),
                        e = c.attr("target"),
                        j = c.attr("action");
                    if (!j && (j = h(c), j === w.hrefNoHash)) j = x.hrefNoSearch;
                    j = m.makeUrlAbsolute(j, h(c));
                    m.isExternal(j) && !m.isPermittedCrossDomainRequest(x, j) || e || (a.mobile.changePage(j, {
                        type: d && d.length && d.toLowerCase() || "get",
                        data: c.serialize(),
                        transition: c.jqmData("transition"),
                        direction: c.jqmData("direction"),
                        reloadPage: true
                    }), b.preventDefault())
                }
            });
            a(k).bind("vclick", function (c) {
                if (!(c.which > 1) && a.mobile.linkBindingEnabled && (c = j(c.target), a(c).jqmHijackable().length && c && m.parseUrl(c.getAttribute("href") || "#").hash !== "#")) b(true), l = a(c).closest(".ui-btn").not(".ui-disabled"),
                l.addClass(a.mobile.activeBtnClass)
            });
            a(k).bind("click", function (d) {
                if (a.mobile.linkBindingEnabled) {
                    var e = j(d.target),
                        f = a(e),
                        g;
                    if (e && !(d.which > 1) && f.jqmHijackable().length) {
                        g = function () {
                            t.setTimeout(function () {
                                b(true)
                            }, 200)
                        };
                        if (f.is(":jqmData(rel='back')")) return t.history.back(), false;
                        var k = h(f),
                            e = m.makeUrlAbsolute(f.attr("href") || "#", k);
                        if (!a.mobile.ajaxEnabled && !m.isEmbeddedPage(e)) g();
                        else {
                            if (e.search("#") != -1)
                                if (e = e.replace(/[^#]*#/, "")) e = m.isPath(e) ? m.makeUrlAbsolute(e, k) : m.makeUrlAbsolute("#" +
                                    e, x.hrefNoHash);
                                else {
                                    d.preventDefault();
                                    return
                                }
                            f.is("[rel='external']") || f.is(":jqmData(ajax='false')") || f.is("[target]") || m.isExternal(e) && !m.isPermittedCrossDomainRequest(x, e) ? g() : (g = f.jqmData("transition"), k = (k = f.jqmData("direction")) && k === "reverse" || f.jqmData("back"), f = f.attr("data-" + a.mobile.ns + "rel") || c, a.mobile.changePage(e, {
                                transition: g,
                                reverse: k,
                                role: f
                            }), d.preventDefault())
                        }
                    }
                }
            });
            a(k).delegate(".ui-page", "pageshow.prefetch", function () {
                var b = [];
                a(this).find("a:jqmData(prefetch)").each(function () {
                    var c =
                        a(this),
                        d = c.attr("href");
                    d && a.inArray(d, b) === -1 && (b.push(d), a.mobile.loadPage(d, {
                        role: c.attr("data-" + a.mobile.ns + "rel")
                    }))
                })
            });
            a.mobile._handleHashChange = function (b) {
                var d = m.stripHash(b),
                    e = {
                        transition: a.mobile.urlHistory.stack.length === 0 ? "none" : c,
                        changeHash: false,
                        fromHashChange: true
                    };
                if (0 === n.stack.length) n.initialDst = d;
                if (!a.mobile.hashListeningEnabled || n.ignoreNextHashChange) n.ignoreNextHashChange = false;
                else {
                    if (n.stack.length > 1 && d.indexOf(s) > -1 && n.initialDst !== d)
                        if (a.mobile.activePage.is(".ui-dialog")) n.directHashChange({
                            currentUrl: d,
                            either: function (b) {
                                var c = a.mobile.urlHistory.getActive();
                                d = c.pageUrl;
                                a.extend(e, {
                                    role: c.role,
                                    transition: c.transition,
                                    reverse: b
                                })
                            }
                        });
                        else {
                            n.directHashChange({
                                currentUrl: d,
                                isBack: function () {
                                    t.history.back()
                                },
                                isForward: function () {
                                    t.history.forward()
                                }
                            });
                            return
                        }
                    d ? (d = typeof d === "string" && !m.isPath(d) ? m.makeUrlAbsolute("#" + d, w) : d, a.mobile.changePage(d, e)) : a.mobile.changePage(a.mobile.firstPage, e)
                }
            };
            q.bind("hashchange", function () {
                a.mobile._handleHashChange(location.hash)
            });
            a(k).bind("pageshow", g);
            a(t).bind("throttledresize",
                g)
        })
    })(l);
    (function (a, c) {
        var b = {}, d = a(c),
            e = a.mobile.path.parseUrl(location.href),
            g = a.Deferred(),
            f = a.Deferred();
        a(k).ready(a.proxy(f, "resolve"));
        a(k).one("mobileinit", a.proxy(g, "resolve"));
        a.extend(b, {
            initialFilePath: e.pathname + e.search,
            hashChangeTimeout: 200,
            hashChangeEnableTimer: E,
            initialHref: e.hrefNoHash,
            state: function () {
                return {
                    hash: location.hash || "#" + b.initialFilePath,
                    title: k.title,
                    initialHref: b.initialHref
                }
            },
            resetUIKeys: function (b) {
                var c = "&" + a.mobile.subPageUrlKey,
                    d = b.indexOf(a.mobile.dialogHashKey);
                d > -1 ? b = b.slice(0, d) + "#" + b.slice(d) : b.indexOf(c) > -1 && (b = b.split(c).join("#" + c));
                return b
            },
            nextHashChangePrevented: function (c) {
                a.mobile.urlHistory.ignoreNextHashChange = c;
                b.onHashChangeDisabled = c
            },
            onHashChange: function () {
                if (!b.onHashChangeDisabled) {
                    var c, d;
                    c = location.hash;
                    var e = a.mobile.path.isPath(c),
                        f = e ? location.href : a.mobile.getDocumentUrl();
                    c = e ? c.replace("#", "") : c;
                    d = b.state();
                    c = a.mobile.path.makeUrlAbsolute(c, f);
                    e && (c = b.resetUIKeys(c));
                    history.replaceState(d, k.title, c)
                }
            },
            onPopState: function (c) {
                if (c =
                    c.originalEvent.state) clearTimeout(b.hashChangeEnableTimer), b.nextHashChangePrevented(false), a.mobile._handleHashChange(c.hash), b.nextHashChangePrevented(true), b.hashChangeEnableTimer = setTimeout(function () {
                    b.nextHashChangePrevented(false)
                }, b.hashChangeTimeout)
            },
            init: function () {
                d.bind("hashchange", b.onHashChange);
                d.bind("popstate", b.onPopState);
                location.hash === "" && history.replaceState(b.state(), k.title, location.href)
            }
        });
        a.when(f, g, a.mobile.navreadyDeferred).done(function () {
            a.mobile.pushStateEnabled &&
                a.support.pushState && b.init()
        })
    })(l, this);
    l.mobile.transitionFallbacks.pop = "fade";
    (function (a) {
        a.mobile.transitionHandlers.slide = a.mobile.transitionHandlers.simultaneous;
        a.mobile.transitionFallbacks.slide = "fade"
    })(l, this);
    l.mobile.transitionFallbacks.slidedown = "fade";
    l.mobile.transitionFallbacks.slideup = "fade";
    l.mobile.transitionFallbacks.flip = "fade";
    l.mobile.transitionFallbacks.flow = "fade";
    l.mobile.transitionFallbacks.turn = "fade";
    (function (a) {
        a.mobile.page.prototype.options.degradeInputs = {
            color: false,
            date: false,
            datetime: false,
            "datetime-local": false,
            email: false,
            month: false,
            number: false,
            range: "number",
            search: "text",
            tel: false,
            time: false,
            url: false,
            week: false
        };
        a(k).bind("pagecreate create", function (c) {
            var b = a.mobile.closestPageData(a(c.target)),
                d;
            if (b) d = b.options, a(c.target).find("input").not(b.keepNativeSelector()).each(function () {
                var b = a(this),
                    c = this.getAttribute("type"),
                    f = d.degradeInputs[c] || "text";
                if (d.degradeInputs[c]) {
                    var j = a("<div>").html(b.clone()).html(),
                        h = j.indexOf(" type=") > -1;
                    b.replaceWith(j.replace(h ?
                        /\s+type=["']?\w+['"]?/ : /\/?>/, ' type="' + f + '" data-' + a.mobile.ns + 'type="' + c + '"' + (h ? "" : ">")))
                }
            })
        })
    })(l);
    (function (a, c) {
        a.widget("mobile.dialog", a.mobile.widget, {
            options: {
                closeBtnText: "Close",
                overlayTheme: "a",
                initSelector: ":jqmData(role='dialog')"
            },
            _create: function () {
                var b = this,
                    c = this.element,
                    e = a("<a href='#' data-" + a.mobile.ns + "icon='delete' data-" + a.mobile.ns + "iconpos='notext'>" + this.options.closeBtnText + "</a>"),
                    g = a("<div/>", {
                        role: "dialog",
                        "class": "ui-dialog-contain ui-corner-all ui-overlay-shadow"
                    });
                c.addClass("ui-dialog ui-overlay-" + this.options.overlayTheme);
                c.wrapInner(g).children().find(":jqmData(role='header')").prepend(e).end().children(":first-child").addClass("ui-corner-top").end().children(":last-child").addClass("ui-corner-bottom");
                e.bind("click", function () {
                    b.close()
                });
                c.bind("vclick submit", function (b) {
                    var b = a(b.target).closest(b.type === "vclick" ? "a" : "form"),
                        c;
                    b.length && !b.jqmData("transition") && (c = a.mobile.urlHistory.getActive() || {}, b.attr("data-" + a.mobile.ns + "transition", c.transition ||
                        a.mobile.defaultDialogTransition).attr("data-" + a.mobile.ns + "direction", "reverse"))
                }).bind("pagehide", function () {
                    b._isClosed = false;
                    a(this).find("." + a.mobile.activeBtnClass).not(".ui-slider-bg").removeClass(a.mobile.activeBtnClass)
                }).bind("pagebeforeshow", function () {
                    b.options.overlayTheme && b.element.page("removeContainerBackground").page("setContainerBackground", b.options.overlayTheme)
                })
            },
            close: function () {
                if (!this._isClosed) this._isClosed = true, a.mobile.hashListeningEnabled ? c.history.back() : a.mobile.changePage(a.mobile.urlHistory.getPrev().url)
            }
        });
        a(k).delegate(a.mobile.dialog.prototype.options.initSelector, "pagecreate", function () {
            a.mobile.dialog.prototype.enhance(this)
        })
    })(l, this);
    (function (a) {
        a.mobile.page.prototype.options.backBtnText = "Back";
        a.mobile.page.prototype.options.addBackBtn = false;
        a.mobile.page.prototype.options.backBtnTheme = null;
        a.mobile.page.prototype.options.headerTheme = "a";
        a.mobile.page.prototype.options.footerTheme = "a";
        a.mobile.page.prototype.options.contentTheme = null;
        a(k).bind("pagecreate", function (c) {
            var b = a(c.target),
                d =
                    b.data("page").options,
                e = b.jqmData("role"),
                g = d.theme;
            a(":jqmData(role='header'), :jqmData(role='footer'), :jqmData(role='content')", b).jqmEnhanceable().each(function () {
                var c = a(this),
                    j = c.jqmData("role"),
                    h = c.jqmData("theme"),
                    k = h || d.contentTheme || e === "dialog" && g,
                    o;
                c.addClass("ui-" + j);
                if (j === "header" || j === "footer") {
                    var m = h || (j === "header" ? d.headerTheme : d.footerTheme) || g;
                    c.addClass("ui-bar-" + m).attr("role", j === "header" ? "banner" : "contentinfo");
                    j === "header" && (h = c.children("a"), o = h.hasClass("ui-btn-left"),
                        k = h.hasClass("ui-btn-right"), o = o || h.eq(0).not(".ui-btn-right").addClass("ui-btn-left").length, k || h.eq(1).addClass("ui-btn-right"));
                    d.addBackBtn && j === "header" && a(".ui-page").length > 1 && b.jqmData("url") !== a.mobile.path.stripHash(location.hash) && !o && a("<a href='javascript:void(0);' class='ui-btn-left' data-" + a.mobile.ns + "rel='back' data-" + a.mobile.ns + "icon='arrow-l'>" + d.backBtnText + "</a>").attr("data-" + a.mobile.ns + "theme", d.backBtnTheme || m).prependTo(c);
                    c.children("h1, h2, h3, h4, h5, h6").addClass("ui-title").attr({
                        role: "heading",
                        "aria-level": "1"
                    })
                } else j === "content" && (k && c.addClass("ui-body-" + k), c.attr("role", "main"))
            })
        })
    })(l);
    (function (a) {
        a.fn.fieldcontain = function () {
            return this.addClass("ui-field-contain ui-body ui-br").contents().filter(function () {
                return this.nodeType === 3 && !/\S/.test(this.nodeValue)
            }).remove()
        };
        a(k).bind("pagecreate create", function (c) {
            a(":jqmData(role='fieldcontain')", c.target).jqmEnhanceable().fieldcontain()
        })
    })(l);
    (function (a) {
        a.fn.grid = function (c) {
            return this.each(function () {
                var b = a(this),
                    d = a.extend({
                            grid: null
                        },
                        c),
                    e = b.children(),
                    g = {
                        solo: 1,
                        a: 2,
                        b: 3,
                        c: 4,
                        d: 5
                    }, d = d.grid;
                if (!d)
                    if (e.length <= 5)
                        for (var f in g) g[f] === e.length && (d = f);
                    else d = "a", b.addClass("ui-grid-duo");
                g = g[d];
                b.addClass("ui-grid-" + d);
                e.filter(":nth-child(" + g + "n+1)").addClass("ui-block-a");
                g > 1 && e.filter(":nth-child(" + g + "n+2)").addClass("ui-block-b");
                g > 2 && e.filter(":nth-child(3n+3)").addClass("ui-block-c");
                g > 3 && e.filter(":nth-child(4n+4)").addClass("ui-block-d");
                g > 4 && e.filter(":nth-child(5n+5)").addClass("ui-block-e")
            })
        }
    })(l);
    (function (a) {
        a(k).bind("pagecreate create",
            function (c) {
                a(":jqmData(role='nojs')", c.target).addClass("ui-nojs")
            })
    })(l);
    (function (a, c) {
        function b(a) {
            for (var b; a;) {
                if ((b = typeof a.className === "string" && a.className + " ") && b.indexOf("ui-btn ") > -1 && b.indexOf("ui-disabled ") < 0) break;
                a = a.parentNode
            }
            return a
        }
        a.fn.buttonMarkup = function (b) {
            for (var b = b && a.type(b) == "object" ? b : {}, g = 0; g < this.length; g++) {
                var f = this.eq(g),
                    j = f[0],
                    h = a.extend({}, a.fn.buttonMarkup.defaults, {
                        icon: b.icon !== c ? b.icon : f.jqmData("icon"),
                        iconpos: b.iconpos !== c ? b.iconpos : f.jqmData("iconpos"),
                        theme: b.theme !== c ? b.theme : f.jqmData("theme") || a.mobile.getInheritedTheme(f, "c"),
                        inline: b.inline !== c ? b.inline : f.jqmData("inline"),
                        shadow: b.shadow !== c ? b.shadow : f.jqmData("shadow"),
                        corners: b.corners !== c ? b.corners : f.jqmData("corners"),
                        iconshadow: b.iconshadow !== c ? b.iconshadow : f.jqmData("iconshadow"),
                        mini: b.mini !== c ? b.mini : f.jqmData("mini")
                    }, b),
                    q = "ui-btn-inner",
                    o, m, l, n, r, p;
                a.each(h, function (b, c) {
                    j.setAttribute("data-" + a.mobile.ns + b, c);
                    f.jqmData(b, c)
                });
                (p = a.data(j.tagName === "INPUT" || j.tagName === "BUTTON" ?
                    j.parentNode : j, "buttonElements")) ? (j = p.outer, f = a(j), l = p.inner, n = p.text, a(p.icon).remove(), p.icon = null) : (l = k.createElement(h.wrapperEls), n = k.createElement(h.wrapperEls));
                r = h.icon ? k.createElement("span") : null;
                d && !p && d();
                if (!h.theme) h.theme = a.mobile.getInheritedTheme(f, "c");
                o = "ui-btn ui-btn-up-" + h.theme;
                o += h.inline ? " ui-btn-inline" : "";
                o += h.shadow ? " ui-shadow" : "";
                o += h.corners ? " ui-btn-corner-all" : "";
                h.mini !== c && (o += h.mini ? " ui-mini" : " ui-fullsize");
                h.inline !== c && (o += h.inline === false ? " ui-btn-block" : " ui-btn-inline");
                if (h.icon) h.icon = "ui-icon-" + h.icon, h.iconpos = h.iconpos || "left", m = "ui-icon " + h.icon, h.iconshadow && (m += " ui-icon-shadow");
                h.iconpos && (o += " ui-btn-icon-" + h.iconpos, h.iconpos == "notext" && !f.attr("title") && f.attr("title", f.getEncodedText()));
                q += h.corners ? " ui-btn-corner-all" : "";
                h.iconpos && h.iconpos === "notext" && !f.attr("title") && f.attr("title", f.getEncodedText());
                p && f.removeClass(p.bcls || "");
                f.removeClass("ui-link").addClass(o);
                l.className = q;
                n.className = "ui-btn-text";
                p || l.appendChild(n);
                if (r && (r.className =
                    m, !p || !p.icon)) r.appendChild(k.createTextNode("\u00a0")), l.appendChild(r);
                for (; j.firstChild && !p;) n.appendChild(j.firstChild);
                p || j.appendChild(l);
                p = {
                    bcls: o,
                    outer: j,
                    inner: l,
                    text: n,
                    icon: r
                };
                a.data(j, "buttonElements", p);
                a.data(l, "buttonElements", p);
                a.data(n, "buttonElements", p);
                r && a.data(r, "buttonElements", p)
            }
            return this
        };
        a.fn.buttonMarkup.defaults = {
            corners: true,
            shadow: true,
            iconshadow: true,
            wrapperEls: "span"
        };
        var d = function () {
            var c = a.mobile.buttonMarkup.hoverDelay,
                g, f;
            a(k).bind({
                "vmousedown vmousecancel vmouseup vmouseover vmouseout focus blur scrollstart": function (d) {
                    var h,
                        k = a(b(d.target)),
                        d = d.type;
                    if (k.length)
                        if (h = k.attr("data-" + a.mobile.ns + "theme"), d === "vmousedown") a.support.touch ? g = setTimeout(function () {
                            k.removeClass("ui-btn-up-" + h).addClass("ui-btn-down-" + h)
                        }, c) : k.removeClass("ui-btn-up-" + h).addClass("ui-btn-down-" + h);
                        else if (d === "vmousecancel" || d === "vmouseup") k.removeClass("ui-btn-down-" + h).addClass("ui-btn-up-" + h);
                    else if (d === "vmouseover" || d === "focus") a.support.touch ? f = setTimeout(function () {
                        k.removeClass("ui-btn-up-" + h).addClass("ui-btn-hover-" + h)
                    }, c) : k.removeClass("ui-btn-up-" +
                        h).addClass("ui-btn-hover-" + h);
                    else if (d === "vmouseout" || d === "blur" || d === "scrollstart") k.removeClass("ui-btn-hover-" + h + " ui-btn-down-" + h).addClass("ui-btn-up-" + h), g && clearTimeout(g), f && clearTimeout(f)
                },
                "focusin focus": function (c) {
                    a(b(c.target)).addClass(a.mobile.focusClass)
                },
                "focusout blur": function (c) {
                    a(b(c.target)).removeClass(a.mobile.focusClass)
                }
            });
            d = null
        };
        a(k).bind("pagecreate create", function (b) {
            a(":jqmData(role='button'), .ui-bar > a, .ui-header > a, .ui-footer > a, .ui-bar > :jqmData(role='controlgroup') > a",
                b.target).not(".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')").buttonMarkup()
        })
    })(l);
    (function (a) {
        a.widget("mobile.collapsible", a.mobile.widget, {
            options: {
                expandCueText: " click to expand contents",
                collapseCueText: " click to collapse contents",
                collapsed: true,
                heading: "h1,h2,h3,h4,h5,h6,legend",
                theme: null,
                contentTheme: null,
                iconTheme: "d",
                mini: false,
                initSelector: ":jqmData(role='collapsible')"
            },
            _create: function () {
                var c = this.element,
                    b = this.options,
                    d = c.addClass("ui-collapsible"),
                    e = c.children(b.heading).first(),
                    g = d.wrapInner("<div class='ui-collapsible-content'></div>").find(".ui-collapsible-content"),
                    f = c.closest(":jqmData(role='collapsible-set')").addClass("ui-collapsible-set");
                e.is("legend") && (e = a("<div role='heading'>" + e.html() + "</div>").insertBefore(e), e.next().remove());
                if (f.length) {
                    if (!b.theme) b.theme = f.jqmData("theme") || a.mobile.getInheritedTheme(f, "c");
                    if (!b.contentTheme) b.contentTheme = f.jqmData("content-theme");
                    if (!b.iconPos) b.iconPos = f.jqmData("iconpos");
                    if (!b.mini) b.mini = f.jqmData("mini")
                }
                g.addClass(b.contentTheme ?
                    "ui-body-" + b.contentTheme : "");
                e.insertBefore(g).addClass("ui-collapsible-heading").append("<span class='ui-collapsible-heading-status'></span>").wrapInner("<a href='#' class='ui-collapsible-heading-toggle'></a>").find("a").first().buttonMarkup({
                    shadow: false,
                    corners: false,
                    iconpos: c.jqmData("iconpos") || b.iconPos || "left",
                    icon: "plus",
                    mini: b.mini,
                    theme: b.theme
                }).add(".ui-btn-inner", c).addClass("ui-corner-top ui-corner-bottom");
                d.bind("expand collapse", function (c) {
                    if (!c.isDefaultPrevented()) {
                        c.preventDefault();
                        var h = a(this),
                            c = c.type === "collapse",
                            k = b.contentTheme;
                        e.toggleClass("ui-collapsible-heading-collapsed", c).find(".ui-collapsible-heading-status").text(c ? b.expandCueText : b.collapseCueText).end().find(".ui-icon").toggleClass("ui-icon-minus", !c).toggleClass("ui-icon-plus", c).end().find("a").first().removeClass(a.mobile.activeBtnClass);
                        h.toggleClass("ui-collapsible-collapsed", c);
                        g.toggleClass("ui-collapsible-content-collapsed", c).attr("aria-hidden", c);
                        if (k && (!f.length || d.jqmData("collapsible-last"))) e.find("a").first().add(e.find(".ui-btn-inner")).toggleClass("ui-corner-bottom",
                            c), g.toggleClass("ui-corner-bottom", !c);
                        g.trigger("updatelayout")
                    }
                }).trigger(b.collapsed ? "collapse" : "expand");
                e.bind("tap", function () {
                    e.find("a").first().addClass(a.mobile.activeBtnClass)
                }).bind("click", function (a) {
                    var b = e.is(".ui-collapsible-heading-collapsed") ? "expand" : "collapse";
                    d.trigger(b);
                    a.preventDefault();
                    a.stopPropagation()
                })
            }
        });
        a(k).bind("pagecreate create", function (c) {
            a.mobile.collapsible.prototype.enhanceWithin(c.target)
        })
    })(l);
    (function (a, c) {
        a.widget("mobile.collapsibleset", a.mobile.widget, {
            options: {
                initSelector: ":jqmData(role='collapsible-set')"
            },
            _create: function () {
                var b = this.element.addClass("ui-collapsible-set"),
                    d = this.options;
                if (!d.theme) d.theme = a.mobile.getInheritedTheme(b, "c");
                if (!d.contentTheme) d.contentTheme = b.jqmData("content-theme");
                if (!d.corners) d.corners = b.jqmData("corners") === c ? true : false;
                b.jqmData("collapsiblebound") || b.jqmData("collapsiblebound", true).bind("expand collapse", function (b) {
                    var c = b.type === "collapse",
                        b = a(b.target).closest(".ui-collapsible"),
                        d = b.data("collapsible");
                    d.options.contentTheme && b.jqmData("collapsible-last") && (b.find(d.options.heading).first().find("a").first().toggleClass("ui-corner-bottom", c).find(".ui-btn-inner").toggleClass("ui-corner-bottom", c), b.find(".ui-collapsible-content").toggleClass("ui-corner-bottom", !c))
                }).bind("expand", function (b) {
                    a(b.target).closest(".ui-collapsible").siblings(".ui-collapsible").trigger("collapse")
                })
            },
            _init: function () {
                this.refresh()
            },
            refresh: function () {
                var b = this.options,
                    c = this.element.children(":jqmData(role='collapsible')");
                a.mobile.collapsible.prototype.enhance(c.not(".ui-collapsible"));
                c.each(function () {
                    a(this).find(a.mobile.collapsible.prototype.options.heading).find("a").first().removeClass("ui-corner-top ui-corner-bottom").find(".ui-btn-inner").removeClass("ui-corner-top ui-corner-bottom")
                });
                c.first().find("a").first().addClass(b.corners ? "ui-corner-top" : "").find(".ui-btn-inner").addClass("ui-corner-top");
                c.last().jqmData("collapsible-last", true).find("a").first().addClass(b.corners ? "ui-corner-bottom" : "").find(".ui-btn-inner").addClass("ui-corner-bottom")
            }
        });
        a(k).bind("pagecreate create", function (b) {
            a.mobile.collapsibleset.prototype.enhanceWithin(b.target)
        })
    })(l);
    (function (a, c) {
        a.widget("mobile.navbar", a.mobile.widget, {
            options: {
                iconpos: "top",
                grid: null,
                initSelector: ":jqmData(role='navbar')"
            },
            _create: function () {
                var b = this.element,
                    d = b.find("a"),
                    e = d.filter(":jqmData(icon)").length ? this.options.iconpos : c;
                b.addClass("ui-navbar ui-mini").attr("role", "navigation").find("ul").jqmEnhanceable().grid({
                    grid: this.options.grid
                });
                d.buttonMarkup({
                    corners: false,
                    shadow: false,
                    inline: true,
                    iconpos: e
                });
                b.delegate("a", "vclick", function (b) {
                    a(b.target).hasClass("ui-disabled") || (d.removeClass(a.mobile.activeBtnClass), a(this).addClass(a.mobile.activeBtnClass))
                });
                b.closest(".ui-page").bind("pagebeforeshow", function () {
                    d.filter(".ui-state-persist").addClass(a.mobile.activeBtnClass)
                })
            }
        });
        a(k).bind("pagecreate create", function (b) {
            a.mobile.navbar.prototype.enhanceWithin(b.target)
        })
    })(l);
    (function (a) {
        var c = {};
        a.widget("mobile.listview", a.mobile.widget, {
            options: {
                theme: null,
                countTheme: "c",
                headerTheme: "b",
                dividerTheme: "b",
                splitIcon: "arrow-r",
                splitTheme: "b",
                inset: false,
                initSelector: ":jqmData(role='listview')"
            },
            _create: function () {
                var a = "";
                a += this.options.inset ? " ui-listview-inset ui-corner-all ui-shadow " : "";
                this.element.addClass(function (c, e) {
                    return e + " ui-listview " + a
                });
                this.refresh(true)
            },
            _removeCorners: function (a, c) {
                a = a.add(a.find(".ui-btn-inner, .ui-li-link-alt, .ui-li-thumb"));
                c === "top" ? a.removeClass("ui-corner-top ui-corner-tr ui-corner-tl") : c === "bottom" ? a.removeClass("ui-corner-bottom ui-corner-br ui-corner-bl") :
                    a.removeClass("ui-corner-top ui-corner-tr ui-corner-tl ui-corner-bottom ui-corner-br ui-corner-bl")
            },
            _refreshCorners: function (a) {
                var c, e;
                this.options.inset && (c = this.element.children("li"), e = a ? c.not(".ui-screen-hidden") : c.filter(":visible"), this._removeCorners(c), c = e.first().addClass("ui-corner-top"), c.add(c.find(".ui-btn-inner").not(".ui-li-link-alt span:first-child")).addClass("ui-corner-top").end().find(".ui-li-link-alt, .ui-li-link-alt span:first-child").addClass("ui-corner-tr").end().find(".ui-li-thumb").not(".ui-li-icon").addClass("ui-corner-tl"),
                    e = e.last().addClass("ui-corner-bottom"), e.add(e.find(".ui-btn-inner")).find(".ui-li-link-alt").addClass("ui-corner-br").end().find(".ui-li-thumb").not(".ui-li-icon").addClass("ui-corner-bl"));
                a || this.element.trigger("updatelayout")
            },
            _findFirstElementByTagName: function (a, c, e, g) {
                var f = {};
                for (f[e] = f[g] = true; a;) {
                    if (f[a.nodeName]) return a;
                    a = a[c]
                }
                return null
            },
            _getChildrenByTagName: function (b, c, e) {
                var g = [],
                    f = {};
                f[c] = f[e] = true;
                for (b = b.firstChild; b;) f[b.nodeName] && g.push(b), b = b.nextSibling;
                return a(g)
            },
            _addThumbClasses: function (b) {
                var c,
                    e, g = b.length;
                for (c = 0; c < g; c++) e = a(this._findFirstElementByTagName(b[c].firstChild, "nextSibling", "img", "IMG")), e.length && (e.addClass("ui-li-thumb"), a(this._findFirstElementByTagName(e[0].parentNode, "parentNode", "li", "LI")).addClass(e.is(".ui-li-icon") ? "ui-li-has-icon" : "ui-li-has-thumb"))
            },
            refresh: function (b) {
                this.parentPage = this.element.closest(".ui-page");
                this._createSubPages();
                var c = this.options,
                    e = this.element,
                    g = e.jqmData("dividertheme") || c.dividerTheme,
                    f = e.jqmData("splittheme"),
                    j = e.jqmData("spliticon"),
                    h = this._getChildrenByTagName(e[0], "li", "LI"),
                    l = a.support.cssPseudoElement || !a.nodeName(e[0], "ol") ? 0 : 1,
                    o = {}, m, v, n, r, p, s, u;
                l && e.find(".ui-li-dec").remove();
                if (!c.theme) c.theme = a.mobile.getInheritedTheme(this.element, "c");
                for (var x = 0, w = h.length; x < w; x++) {
                    m = h.eq(x);
                    v = "ui-li";
                    if (b || !m.hasClass("ui-li")) n = m.jqmData("theme") || c.theme, r = this._getChildrenByTagName(m[0], "a", "A"), s = m.jqmData("role") === "list-divider", r.length && !s ? (s = m.jqmData("icon"), m.buttonMarkup({
                        wrapperEls: "div",
                        shadow: false,
                        corners: false,
                        iconpos: "right",
                        icon: r.length > 1 || s === false ? false : s || "arrow-r",
                        theme: n
                    }), s != false && r.length == 1 && m.addClass("ui-li-has-arrow"), r.first().removeClass("ui-link").addClass("ui-link-inherit"), r.length > 1 && (v += " ui-li-has-alt", r = r.last(), p = f || r.jqmData("theme") || c.splitTheme, u = r.jqmData("icon"), r.appendTo(m).attr("title", r.getEncodedText()).addClass("ui-li-link-alt").empty().buttonMarkup({
                        shadow: false,
                        corners: false,
                        theme: n,
                        icon: false,
                        iconpos: "notext"
                    }).find(".ui-btn-inner").append(a(k.createElement("span")).buttonMarkup({
                        shadow: true,
                        corners: true,
                        theme: p,
                        iconpos: "notext",
                        icon: u || s || j || c.splitIcon
                    })))) : s ? (v += " ui-li-divider ui-bar-" + g, m.attr("role", "heading"), l && (l = 1)) : v += " ui-li-static ui-body-" + n;
                    l && v.indexOf("ui-li-divider") < 0 && (n = m.is(".ui-li-static:first") ? m : m.find(".ui-link-inherit"), n.addClass("ui-li-jsnumbering").prepend("<span class='ui-li-dec'>" + l+++". </span>"));
                    o[v] || (o[v] = []);
                    o[v].push(m[0])
                }
                for (v in o) a(o[v]).addClass(v).children(".ui-btn-inner").addClass(v);
                e.find("h1, h2, h3, h4, h5, h6").addClass("ui-li-heading").end().find("p, dl").addClass("ui-li-desc").end().find(".ui-li-aside").each(function () {
                    var b =
                        a(this);
                    b.prependTo(b.parent())
                }).end().find(".ui-li-count").each(function () {
                    a(this).closest("li").addClass("ui-li-has-count")
                }).addClass("ui-btn-up-" + (e.jqmData("counttheme") || this.options.countTheme) + " ui-btn-corner-all");
                this._addThumbClasses(h);
                this._addThumbClasses(e.find(".ui-link-inherit"));
                this._refreshCorners(b)
            },
            _idStringEscape: function (a) {
                return a.replace(/[^a-zA-Z0-9]/g, "-")
            },
            _createSubPages: function () {
                var b = this.element,
                    d = b.closest(".ui-page"),
                    e = d.jqmData("url"),
                    g = e || d[0][a.expando],
                    f = b.attr("id"),
                    j = this.options,
                    h = "data-" + a.mobile.ns,
                    k = this,
                    l = d.find(":jqmData(role='footer')").jqmData("id"),
                    m;
                typeof c[g] === "undefined" && (c[g] = -1);
                f = f || ++c[g];
                a(b.find("li>ul, li>ol").toArray().reverse()).each(function (c) {
                    var d = a(this),
                        g = d.attr("id") || f + "-" + c,
                        c = d.parent(),
                        k = a(d.prevAll().toArray().reverse()),
                        k = k.length ? k : a("<span>" + a.trim(c.contents()[0].nodeValue) + "</span>"),
                        q = k.first().getEncodedText(),
                        g = (e || "") + "&" + a.mobile.subPageUrlKey + "=" + g,
                        u = d.jqmData("theme") || j.theme,
                        x = d.jqmData("counttheme") ||
                            b.jqmData("counttheme") || j.countTheme;
                    m = true;
                    d.detach().wrap("<div " + h + "role='page' " + h + "url='" + g + "' " + h + "theme='" + u + "' " + h + "count-theme='" + x + "'><div " + h + "role='content'></div></div>").parent().before("<div " + h + "role='header' " + h + "theme='" + j.headerTheme + "'><div class='ui-title'>" + q + "</div></div>").after(l ? a("<div " + h + "role='footer' " + h + "id='" + l + "'>") : "").parent().appendTo(a.mobile.pageContainer).page();
                    d = c.find("a:first");
                    d.length || (d = a("<a/>").html(k || q).prependTo(c.empty()));
                    d.attr("href", "#" + g)
                }).listview();
                m && d.is(":jqmData(external-page='true')") && d.data("page").options.domCache === false && d.unbind("pagehide.remove").bind("pagehide.remove", function (b, c) {
                    var f = c.nextPage,
                        h = new a.Event("pageremove");
                    c.nextPage && (f = f.jqmData("url"), f.indexOf(e + "&" + a.mobile.subPageUrlKey) !== 0 && (k.childPages().remove(), d.trigger(h), h.isDefaultPrevented() || d.removeWithDependents()))
                })
            },
            childPages: function () {
                var b = this.parentPage.jqmData("url");
                return a(":jqmData(url^='" + b + "&" + a.mobile.subPageUrlKey + "')")
            }
        });
        a(k).bind("pagecreate create",
            function (b) {
                a.mobile.listview.prototype.enhanceWithin(b.target)
            })
    })(l);
    (function (a, c) {
        a.widget("mobile.checkboxradio", a.mobile.widget, {
            options: {
                theme: null,
                initSelector: "input[type='checkbox'],input[type='radio']"
            },
            _create: function () {
                var b = this,
                    d = this.element,
                    e = a(d).closest("label"),
                    g = e.length ? e : a(d).closest("form,fieldset,:jqmData(role='page'),:jqmData(role='dialog')").find("label").filter("[for='" + d[0].id + "']"),
                    f = d[0].type,
                    e = d.jqmData("mini") || d.closest("form,fieldset").jqmData("mini"),
                    j = f + "-on",
                    h = f + "-off",
                    l = d.parents(":jqmData(type='horizontal')").length ? c : h,
                    o = d.jqmData("iconpos") || d.closest("form,fieldset").jqmData("iconpos");
                if (!(f !== "checkbox" && f !== "radio")) {
                    a.extend(this, {
                        label: g,
                        inputtype: f,
                        checkedClass: "ui-" + j + (l ? "" : " " + a.mobile.activeBtnClass),
                        uncheckedClass: "ui-" + h,
                        checkedicon: "ui-icon-" + j,
                        uncheckedicon: "ui-icon-" + h
                    });
                    if (!this.options.theme) this.options.theme = a.mobile.getInheritedTheme(this.element, "c");
                    g.buttonMarkup({
                        theme: this.options.theme,
                        icon: l,
                        shadow: false,
                        mini: e,
                        iconpos: o
                    });
                    e = k.createElement("div");
                    e.className = "ui-" + f;
                    d.add(g).wrapAll(e);
                    g.bind({
                        vmouseover: function (b) {
                            a(this).parent().is(".ui-disabled") && b.stopPropagation()
                        },
                        vclick: function (a) {
                            if (d.is(":disabled")) a.preventDefault();
                            else return b._cacheVals(), d.prop("checked", f === "radio" && true || !d.prop("checked")), d.triggerHandler("click"), b._getInputSet().not(d).prop("checked", false), b._updateAll(), false
                        }
                    });
                    d.bind({
                        vmousedown: function () {
                            b._cacheVals()
                        },
                        vclick: function () {
                            var c = a(this);
                            c.is(":checked") ? (c.prop("checked",
                                true), b._getInputSet().not(c).prop("checked", false)) : c.prop("checked", false);
                            b._updateAll()
                        },
                        focus: function () {
                            g.addClass(a.mobile.focusClass)
                        },
                        blur: function () {
                            g.removeClass(a.mobile.focusClass)
                        }
                    });
                    this.refresh()
                }
            },
            _cacheVals: function () {
                this._getInputSet().each(function () {
                    a(this).jqmData("cacheVal", this.checked)
                })
            },
            _getInputSet: function () {
                return this.inputtype === "checkbox" ? this.element : this.element.closest("form,fieldset,:jqmData(role='page')").find("input[name='" + this.element[0].name + "'][type='" +
                    this.inputtype + "']")
            },
            _updateAll: function () {
                var b = this;
                this._getInputSet().each(function () {
                    var c = a(this);
                    (this.checked || b.inputtype === "checkbox") && c.trigger("change")
                }).checkboxradio("refresh")
            },
            refresh: function () {
                var a = this.element[0],
                    c = this.label,
                    e = c.find(".ui-icon");
                a.checked ? (c.addClass(this.checkedClass).removeClass(this.uncheckedClass), e.addClass(this.checkedicon).removeClass(this.uncheckedicon)) : (c.removeClass(this.checkedClass).addClass(this.uncheckedClass), e.removeClass(this.checkedicon).addClass(this.uncheckedicon));
                a.disabled ? this.disable() : this.enable()
            },
            disable: function () {
                this.element.prop("disabled", true).parent().addClass("ui-disabled")
            },
            enable: function () {
                this.element.prop("disabled", false).parent().removeClass("ui-disabled")
            }
        });
        a(k).bind("pagecreate create", function (b) {
            a.mobile.checkboxradio.prototype.enhanceWithin(b.target, true)
        })
    })(l);
    (function (a, c) {
        a.widget("mobile.button", a.mobile.widget, {
            options: {
                theme: null,
                icon: null,
                iconpos: null,
                inline: false,
                corners: true,
                shadow: true,
                iconshadow: true,
                initSelector: "button, [type='button'], [type='submit'], [type='reset'], [type='image']",
                mini: false
            },
            _create: function () {
                var b = this.element,
                    d, e = this.options,
                    g;
                g = "";
                var f;
                if (b[0].tagName === "A")!b.hasClass("ui-btn") && b.buttonMarkup();
                else {
                    if (!this.options.theme) this.options.theme = a.mobile.getInheritedTheme(this.element, "c");~
                    b[0].className.indexOf("ui-btn-left") && (g = "ui-btn-left");~
                    b[0].className.indexOf("ui-btn-right") && (g = "ui-btn-right");
                    if (b.attr("type") === "submit" || b.attr("type") === "reset") g ? g += " ui-submit" : g = "ui-submit";
                    a("label[for='" + b.attr("id") + "']").addClass("ui-submit");
                    d = this.button =
                        a("<div></div>").text(b.text() || b.val()).insertBefore(b).buttonMarkup({
                            theme: e.theme,
                            icon: e.icon,
                            iconpos: e.iconpos,
                            inline: e.inline,
                            corners: e.corners,
                            shadow: e.shadow,
                            iconshadow: e.iconshadow,
                            mini: e.mini
                        }).addClass(g).append(b.addClass("ui-btn-hidden"));
                    e = b.attr("type");
                    g = b.attr("name");
                    e !== "button" && e !== "reset" && g && b.bind("vclick", function () {
                        f === c && (f = a("<input>", {
                            type: "hidden",
                            name: b.attr("name"),
                            value: b.attr("value")
                        }).insertBefore(b), a(k).one("submit", function () {
                            f.remove();
                            f = c
                        }))
                    });
                    b.bind({
                        focus: function () {
                            d.addClass(a.mobile.focusClass)
                        },
                        blur: function () {
                            d.removeClass(a.mobile.focusClass)
                        }
                    });
                    this.refresh()
                }
            },
            enable: function () {
                this.element.attr("disabled", false);
                this.button.removeClass("ui-disabled").attr("aria-disabled", false);
                return this._setOption("disabled", false)
            },
            disable: function () {
                this.element.attr("disabled", true);
                this.button.addClass("ui-disabled").attr("aria-disabled", true);
                return this._setOption("disabled", true)
            },
            refresh: function () {
                var b = this.element;
                b.prop("disabled") ? this.disable() : this.enable();
                a(this.button.data("buttonElements").text).text(b.text() ||
                    b.val())
            }
        });
        a(k).bind("pagecreate create", function (b) {
            a.mobile.button.prototype.enhanceWithin(b.target, true)
        })
    })(l);
    (function (a) {
        a.fn.controlgroup = function (c) {
            function b(a, b) {
                a.removeClass("ui-btn-corner-all ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-controlgroup-last ui-shadow").eq(0).addClass(b[0]).end().last().addClass(b[1]).addClass("ui-controlgroup-last")
            }
            return this.each(function () {
                var d = a(this),
                    e = a.extend({
                        direction: d.jqmData("type") || "vertical",
                        shadow: false,
                        excludeInvisible: true,
                        mini: d.jqmData("mini")
                    }, c),
                    g = d.children("legend"),
                    f = e.direction == "horizontal" ? ["ui-corner-left", "ui-corner-right"] : ["ui-corner-top", "ui-corner-bottom"];
                d.find("input").first().attr("type");
                d.wrapInner("<div class='ui-controlgroup-controls'></div>");
                g.length && (a("<div role='heading' class='ui-controlgroup-label'>" + g.html() + "</div>").insertBefore(d.children(0)), g.remove());
                d.addClass("ui-corner-all ui-controlgroup ui-controlgroup-" + e.direction);
                b(d.find(".ui-btn" + (e.excludeInvisible ? ":visible" : "")).not(".ui-slider-handle"),
                    f);
                b(d.find(".ui-btn-inner"), f);
                e.shadow && d.addClass("ui-shadow");
                e.mini && d.addClass("ui-mini")
            })
        }
    })(l);
    (function (a) {
        a(k).bind("pagecreate create", function (c) {
            a(c.target).find("a").jqmEnhanceable().not(".ui-btn, .ui-link-inherit, :jqmData(role='none'), :jqmData(role='nojs')").addClass("ui-link")
        })
    })(l);
    (function (a) {
        var c = a("meta[name=viewport]"),
            b = c.attr("content"),
            d = b + ",maximum-scale=1, user-scalable=no",
            e = b + ",maximum-scale=10, user-scalable=yes",
            g = /(user-scalable[\s]*=[\s]*no)|(maximum-scale[\s]*=[\s]*1)[$,\s]/.test(b);
        a.mobile.zoom = a.extend({}, {
            enabled: !g,
            locked: false,
            disable: function (b) {
                if (!g && !a.mobile.zoom.locked) c.attr("content", d), a.mobile.zoom.enabled = false, a.mobile.zoom.locked = b || false
            },
            enable: function (b) {
                if (!g && (!a.mobile.zoom.locked || b === true)) c.attr("content", e), a.mobile.zoom.enabled = true, a.mobile.zoom.locked = false
            },
            restore: function () {
                if (!g) c.attr("content", b), a.mobile.zoom.enabled = true
            }
        })
    })(l);
    (function (a) {
        a.widget("mobile.textinput", a.mobile.widget, {
            options: {
                theme: null,
                preventFocusZoom: /iPhone|iPad|iPod/.test(navigator.platform) &&
                    navigator.userAgent.indexOf("AppleWebKit") > -1,
                initSelector: "input[type='text'], input[type='search'], :jqmData(type='search'), input[type='number'], :jqmData(type='number'), input[type='password'], input[type='email'], input[type='url'], input[type='tel'], textarea, input[type='time'], input[type='date'], input[type='month'], input[type='week'], input[type='datetime'], input[type='datetime-local'], input[type='color'], input:not([type])",
                clearSearchButtonText: "clear text"
            },
            _create: function () {
                var c =
                    this.element,
                    b = this.options,
                    d = b.theme || a.mobile.getInheritedTheme(this.element, "c"),
                    e = " ui-body-" + d,
                    g = c.jqmData("mini") == true,
                    f = g ? " ui-mini" : "",
                    j, h;
                a("label[for='" + c.attr("id") + "']").addClass("ui-input-text");
                j = c.addClass("ui-input-text ui-body-" + d);
                typeof c[0].autocorrect !== "undefined" && !a.support.touchOverflow && (c[0].setAttribute("autocorrect", "off"), c[0].setAttribute("autocomplete", "off"));
                c.is("[type='search'],:jqmData(type='search')") ? (j = c.wrap("<div class='ui-input-search ui-shadow-inset ui-btn-corner-all ui-btn-shadow ui-icon-searchfield" +
                    e + f + "'></div>").parent(), h = a("<a href='#' class='ui-input-clear' title='" + b.clearSearchButtonText + "'>" + b.clearSearchButtonText + "</a>").bind("click", function (a) {
                    c.val("").focus().trigger("change");
                    h.addClass("ui-input-clear-hidden");
                    a.preventDefault()
                }).appendTo(j).buttonMarkup({
                    icon: "delete",
                    iconpos: "notext",
                    corners: true,
                    shadow: true,
                    mini: g
                }), d = function () {
                    setTimeout(function () {
                        h.toggleClass("ui-input-clear-hidden", !c.val())
                    }, 0)
                }, d(), c.bind("paste cut keyup focus change blur", d)) : c.addClass("ui-corner-all ui-shadow-inset" +
                    e + f);
                c.focus(function () {
                    j.addClass(a.mobile.focusClass)
                }).blur(function () {
                    j.removeClass(a.mobile.focusClass)
                }).bind("focus", function () {
                    b.preventFocusZoom && a.mobile.zoom.disable(true)
                }).bind("blur", function () {
                    b.preventFocusZoom && a.mobile.zoom.enable(true)
                });
                if (c.is("textarea")) {
                    var l = function () {
                        var a = c[0].scrollHeight;
                        c[0].clientHeight < a && c.height(a + 15)
                    }, o;
                    c.keyup(function () {
                        clearTimeout(o);
                        o = setTimeout(l, 100)
                    });
                    a(k).one("pagechange", l);
                    a.trim(c.val()) && a(t).load(l)
                }
            },
            disable: function () {
                (this.element.attr("disabled",
                    true).is("[type='search'],:jqmData(type='search')") ? this.element.parent() : this.element).addClass("ui-disabled")
            },
            enable: function () {
                (this.element.attr("disabled", false).is("[type='search'],:jqmData(type='search')") ? this.element.parent() : this.element).removeClass("ui-disabled")
            }
        });
        a(k).bind("pagecreate create", function (c) {
            a.mobile.textinput.prototype.enhanceWithin(c.target, true)
        })
    })(l);
    (function (a) {
        a.mobile.listview.prototype.options.filter = false;
        a.mobile.listview.prototype.options.filterPlaceholder =
            "Filter items...";
        a.mobile.listview.prototype.options.filterTheme = "c";
        a.mobile.listview.prototype.options.filterCallback = function (a, b) {
            return a.toLowerCase().indexOf(b) === -1
        };
        a(k).delegate(":jqmData(role='listview')", "listviewcreate", function () {
            var c = a(this),
                b = c.data("listview");
            if (b.options.filter) {
                var d = a("<form>", {
                    "class": "ui-listview-filter ui-bar-" + b.options.filterTheme,
                    role: "search"
                });
                a("<input>", {
                    placeholder: b.options.filterPlaceholder
                }).attr("data-" + a.mobile.ns + "type", "search").jqmData("lastval",
                    "").bind("keyup change", function () {
                    var d = a(this),
                        g = this.value.toLowerCase(),
                        f = null,
                        f = d.jqmData("lastval") + "",
                        j = false,
                        h = "";
                    d.jqmData("lastval", g);
                    f = g.length < f.length || g.indexOf(f) !== 0 ? c.children() : c.children(":not(.ui-screen-hidden)");
                    if (g) {
                        for (var k = f.length - 1; k >= 0; k--) d = a(f[k]), h = d.jqmData("filtertext") || d.text(), d.is("li:jqmData(role=list-divider)") ? (d.toggleClass("ui-filter-hidequeue", !j), j = false) : b.options.filterCallback(h, g) ? d.toggleClass("ui-filter-hidequeue", true) : j = true;
                        f.filter(":not(.ui-filter-hidequeue)").toggleClass("ui-screen-hidden",
                            false);
                        f.filter(".ui-filter-hidequeue").toggleClass("ui-screen-hidden", true).toggleClass("ui-filter-hidequeue", false)
                    } else f.toggleClass("ui-screen-hidden", false);
                    b._refreshCorners()
                }).appendTo(d).textinput();
                b.options.inset && d.addClass("ui-listview-filter-inset");
                d.bind("submit", function () {
                    return false
                }).insertBefore(c)
            }
        })
    })(l);
    (function (a, c) {
        a.widget("mobile.slider", a.mobile.widget, {
            options: {
                theme: null,
                trackTheme: null,
                disabled: false,
                initSelector: "input[type='range'], :jqmData(type='range'), :jqmData(role='slider')",
                mini: false
            },
            _create: function () {
                var b = this,
                    d = this.element,
                    e = a.mobile.getInheritedTheme(d, "c"),
                    g = this.options.theme || e,
                    e = this.options.trackTheme || e,
                    f = d[0].nodeName.toLowerCase(),
                    j = f == "select" ? "ui-slider-switch" : "",
                    h = d.attr("id"),
                    l = a("[for='" + h + "']"),
                    o = l.attr("id") || h + "-label",
                    l = l.attr("id", o),
                    m = function () {
                        return f == "input" ? parseFloat(d.val()) : d[0].selectedIndex
                    }, v = f == "input" ? parseFloat(d.attr("min")) : 0,
                    n = f == "input" ? parseFloat(d.attr("max")) : d.find("option").length - 1,
                    r = t.parseFloat(d.attr("step") || 1),
                    p = this.options.inline || d.jqmData("inline") == true ? " ui-slider-inline" : "",
                    s = this.options.mini || d.jqmData("mini") ? " ui-slider-mini" : "",
                    u = k.createElement("a"),
                    x = a(u),
                    h = k.createElement("div"),
                    w = a(h),
                    D = d.jqmData("highlight") && f != "select" ? function () {
                        var b = k.createElement("div");
                        b.className = "ui-slider-bg " + a.mobile.activeBtnClass + " ui-btn-corner-all";
                        return a(b).prependTo(w)
                    }() : false;
                u.setAttribute("href", "#");
                h.setAttribute("role", "application");
                h.className = ["ui-slider ", j, " ui-btn-down-", e, " ui-btn-corner-all",
                    p, s
                ].join("");
                u.className = "ui-slider-handle";
                h.appendChild(u);
                x.buttonMarkup({
                    corners: true,
                    theme: g,
                    shadow: true
                }).attr({
                    role: "slider",
                    "aria-valuemin": v,
                    "aria-valuemax": n,
                    "aria-valuenow": m(),
                    "aria-valuetext": m(),
                    title: m(),
                    "aria-labelledby": o
                });
                a.extend(this, {
                    slider: w,
                    handle: x,
                    valuebg: D,
                    dragging: false,
                    beforeStart: null,
                    userModified: false,
                    mouseMoved: false
                });
                if (f == "select") {
                    g = k.createElement("div");
                    g.className = "ui-slider-inneroffset";
                    j = 0;
                    for (o = h.childNodes.length; j < o; j++) g.appendChild(h.childNodes[j]);
                    h.appendChild(g);
                    x.addClass("ui-slider-handle-snapping");
                    g = d.find("option");
                    h = 0;
                    for (j = g.length; h < j; h++) o = !h ? "b" : "a", p = !h ? " ui-btn-down-" + e : " " + a.mobile.activeBtnClass, k.createElement("div"), s = k.createElement("span"), s.className = ["ui-slider-label ui-slider-label-", o, p, " ui-btn-corner-all"].join(""), s.setAttribute("role", "img"), s.appendChild(k.createTextNode(g[h].innerHTML)), a(s).prependTo(w);
                    b._labels = a(".ui-slider-label", w)
                }
                l.addClass("ui-slider");
                d.addClass(f === "input" ? "ui-slider-input" : "ui-slider-switch").change(function () {
                    b.mouseMoved ||
                        b.refresh(m(), true)
                }).keyup(function () {
                    b.refresh(m(), true, true)
                }).blur(function () {
                    b.refresh(m(), true)
                });
                a(k).bind("vmousemove", function (a) {
                    if (b.dragging) return b.mouseMoved = true, f === "select" && x.removeClass("ui-slider-handle-snapping"), b.refresh(a), b.userModified = b.beforeStart !== d[0].selectedIndex, false
                });
                w.bind("vmousedown", function (a) {
                    b.dragging = true;
                    b.userModified = false;
                    b.mouseMoved = false;
                    if (f === "select") b.beforeStart = d[0].selectedIndex;
                    b.refresh(a);
                    return false
                }).bind("vclick", false);
                w.add(k).bind("vmouseup",
                    function () {
                        if (b.dragging) return b.dragging = false, f === "select" && (x.addClass("ui-slider-handle-snapping"), b.mouseMoved ? b.userModified ? b.refresh(b.beforeStart == 0 ? 1 : 0) : b.refresh(b.beforeStart) : b.refresh(b.beforeStart == 0 ? 1 : 0)), b.mouseMoved = false
                    });
                w.insertAfter(d);
                f == "select" && this.handle.bind({
                    focus: function () {
                        w.addClass(a.mobile.focusClass)
                    },
                    blur: function () {
                        w.removeClass(a.mobile.focusClass)
                    }
                });
                this.handle.bind({
                    vmousedown: function () {
                        a(this).focus()
                    },
                    vclick: false,
                    keydown: function (c) {
                        var d = m();
                        if (!b.options.disabled) {
                            switch (c.keyCode) {
                            case a.mobile.keyCode.HOME:
                            case a.mobile.keyCode.END:
                            case a.mobile.keyCode.PAGE_UP:
                            case a.mobile.keyCode.PAGE_DOWN:
                            case a.mobile.keyCode.UP:
                            case a.mobile.keyCode.RIGHT:
                            case a.mobile.keyCode.DOWN:
                            case a.mobile.keyCode.LEFT:
                                if (c.preventDefault(), !b._keySliding) b._keySliding = true, a(this).addClass("ui-state-active")
                            }
                            switch (c.keyCode) {
                            case a.mobile.keyCode.HOME:
                                b.refresh(v);
                                break;
                            case a.mobile.keyCode.END:
                                b.refresh(n);
                                break;
                            case a.mobile.keyCode.PAGE_UP:
                            case a.mobile.keyCode.UP:
                            case a.mobile.keyCode.RIGHT:
                                b.refresh(d + r);
                                break;
                            case a.mobile.keyCode.PAGE_DOWN:
                            case a.mobile.keyCode.DOWN:
                            case a.mobile.keyCode.LEFT:
                                b.refresh(d - r)
                            }
                        }
                    },
                    keyup: function () {
                        if (b._keySliding) b._keySliding = false, a(this).removeClass("ui-state-active")
                    }
                });
                this.refresh(c, c, true)
            },
            refresh: function (b, c, e) {
                (this.options.disabled || this.element.attr("disabled")) && this.disable();
                var g = this.element,
                    f = g[0].nodeName.toLowerCase(),
                    j = f === "input" ? parseFloat(g.attr("min")) : 0,
                    h = f === "input" ? parseFloat(g.attr("max")) : g.find("option").length - 1,
                    k = f === "input" && parseFloat(g.attr("step")) > 0 ? parseFloat(g.attr("step")) : 1;
                if (typeof b === "object") {
                    if (!this.dragging || b.pageX < this.slider.offset().left - 8 || b.pageX > this.slider.offset().left + this.slider.width() + 8) return;
                    b = Math.round((b.pageX - this.slider.offset().left) /
                        this.slider.width() * 100)
                } else b == null && (b = f === "input" ? parseFloat(g.val() || 0) : g[0].selectedIndex), b = (parseFloat(b) - j) / (h - j) * 100; if (!isNaN(b)) {
                    b < 0 && (b = 0);
                    b > 100 && (b = 100);
                    var l = b / 100 * (h - j) + j,
                        m = (l - j) % k;
                    l -= m;
                    Math.abs(m) * 2 >= k && (l += m > 0 ? k : -k);
                    l = parseFloat(l.toFixed(5));
                    l < j && (l = j);
                    l > h && (l = h);
                    this.handle.css("left", b + "%");
                    this.handle.attr({
                        "aria-valuenow": f === "input" ? l : g.find("option").eq(l).attr("value"),
                        "aria-valuetext": f === "input" ? l : g.find("option").eq(l).getEncodedText(),
                        title: f === "input" ? l : g.find("option").eq(l).getEncodedText()
                    });
                    this.valuebg && this.valuebg.css("width", b + "%");
                    if (this._labels) {
                        var j = this.handle.width() / this.slider.width() * 100,
                            t = b && j + (100 - j) * b / 100,
                            n = b === 100 ? 0 : Math.min(j + 100 - t, 100);
                        this._labels.each(function () {
                            var b = a(this).is(".ui-slider-label-a");
                            a(this).width((b ? t : n) + "%")
                        })
                    }
                    if (!e) e = false, f === "input" ? (e = g.val() !== l, g.val(l)) : (e = g[0].selectedIndex !== l, g[0].selectedIndex = l), !c && e && g.trigger("change")
                }
            },
            enable: function () {
                this.element.attr("disabled", false);
                this.slider.removeClass("ui-disabled").attr("aria-disabled",
                    false);
                return this._setOption("disabled", false)
            },
            disable: function () {
                this.element.attr("disabled", true);
                this.slider.addClass("ui-disabled").attr("aria-disabled", true);
                return this._setOption("disabled", true)
            }
        });
        a(k).bind("pagecreate create", function (b) {
            a.mobile.slider.prototype.enhanceWithin(b.target, true)
        })
    })(l);
    (function (a) {
        a.widget("mobile.selectmenu", a.mobile.widget, {
            options: {
                theme: null,
                disabled: false,
                icon: "arrow-d",
                iconpos: "right",
                inline: false,
                corners: true,
                shadow: true,
                iconshadow: true,
                overlayTheme: "a",
                hidePlaceholderMenuItems: true,
                closeText: "Close",
                nativeMenu: true,
                preventFocusZoom: /iPhone|iPad|iPod/.test(navigator.platform) && navigator.userAgent.indexOf("AppleWebKit") > -1,
                initSelector: "select:not(:jqmData(role='slider'))",
                mini: false
            },
            _button: function () {
                return a("<div/>")
            },
            _setDisabled: function (a) {
                this.element.attr("disabled", a);
                this.button.attr("aria-disabled", a);
                return this._setOption("disabled", a)
            },
            _focusButton: function () {
                var a = this;
                setTimeout(function () {
                    a.button.focus()
                }, 40)
            },
            _selectOptions: function () {
                return this.select.find("option")
            },
            _preExtension: function () {
                var c = "";~
                this.element[0].className.indexOf("ui-btn-left") && (c = " ui-btn-left");~
                this.element[0].className.indexOf("ui-btn-right") && (c = " ui-btn-right");
                this.select = this.element.wrap("<div class='ui-select" + c + "'>");
                this.selectID = this.select.attr("id");
                this.label = a("label[for='" + this.selectID + "']").addClass("ui-select");
                this.isMultiple = this.select[0].multiple;
                if (!this.options.theme) this.options.theme = a.mobile.getInheritedTheme(this.select, "c")
            },
            _create: function () {
                this._preExtension();
                this._trigger("beforeCreate");
                this.button = this._button();
                var c = this,
                    b = this.options,
                    d = b.inline || this.select.jqmData("inline"),
                    e = b.mini || this.select.jqmData("mini"),
                    g = b.icon ? b.iconpos || this.select.jqmData("iconpos") : false,
                    d = this.button.text(a(this.select[0].options.item(this.select[0].selectedIndex == -1 ? 0 : this.select[0].selectedIndex)).text()).insertBefore(this.select).buttonMarkup({
                        theme: b.theme,
                        icon: b.icon,
                        iconpos: g,
                        inline: d,
                        corners: b.corners,
                        shadow: b.shadow,
                        iconshadow: b.iconshadow,
                        mini: e
                    });
                b.nativeMenu &&
                    t.opera && t.opera.version && d.addClass("ui-select-nativeonly");
                if (this.isMultiple) this.buttonCount = a("<span>").addClass("ui-li-count ui-btn-up-c ui-btn-corner-all").hide().appendTo(d.addClass("ui-li-has-count"));
                (b.disabled || this.element.attr("disabled")) && this.disable();
                this.select.change(function () {
                    c.refresh()
                });
                this.build()
            },
            build: function () {
                var c = this;
                this.select.appendTo(c.button).bind("vmousedown", function () {
                    c.button.addClass(a.mobile.activeBtnClass)
                }).bind("focus", function () {
                    c.button.addClass(a.mobile.focusClass)
                }).bind("blur",
                    function () {
                        c.button.removeClass(a.mobile.focusClass)
                    }).bind("focus vmouseover", function () {
                    c.button.trigger("vmouseover")
                }).bind("vmousemove", function () {
                    c.button.removeClass(a.mobile.activeBtnClass)
                }).bind("change blur vmouseout", function () {
                    c.button.trigger("vmouseout").removeClass(a.mobile.activeBtnClass)
                }).bind("change blur", function () {
                    c.button.removeClass("ui-btn-down-" + c.options.theme)
                });
                c.button.bind("vmousedown", function () {
                    c.options.preventFocusZoom && a.mobile.zoom.disable(true)
                }).bind("mouseup",
                    function () {
                        c.options.preventFocusZoom && a.mobile.zoom.enable(true)
                    })
            },
            selected: function () {
                return this._selectOptions().filter(":selected")
            },
            selectedIndices: function () {
                var a = this;
                return this.selected().map(function () {
                    return a._selectOptions().index(this)
                }).get()
            },
            setButtonText: function () {
                var c = this,
                    b = this.selected();
                this.button.find(".ui-btn-text").text(function () {
                    return !c.isMultiple ? b.text() : b.length ? b.map(function () {
                        return a(this).text()
                    }).get().join(", ") : c.placeholder
                })
            },
            setButtonCount: function () {
                var a =
                    this.selected();
                this.isMultiple && this.buttonCount[a.length > 1 ? "show" : "hide"]().text(a.length)
            },
            refresh: function () {
                this.setButtonText();
                this.setButtonCount()
            },
            open: a.noop,
            close: a.noop,
            disable: function () {
                this._setDisabled(true);
                this.button.addClass("ui-disabled")
            },
            enable: function () {
                this._setDisabled(false);
                this.button.removeClass("ui-disabled")
            }
        });
        a(k).bind("pagecreate create", function (c) {
            a.mobile.selectmenu.prototype.enhanceWithin(c.target, true)
        })
    })(l);
    (function (a) {
        var c = function (b) {
            var c = b.selectID,
                e = b.label,
                g = b.select.closest(".ui-page"),
                f = a("<div>", {
                    "class": "ui-selectmenu-screen ui-screen-hidden"
                }).appendTo(g),
                j = b._selectOptions(),
                h = b.isMultiple = b.select[0].multiple,
                l = c + "-button",
                o = c + "-menu",
                m = a("<div data-" + a.mobile.ns + "role='dialog' data-" + a.mobile.ns + "theme='" + b.options.theme + "' data-" + a.mobile.ns + "overlay-theme='" + b.options.overlayTheme + "'><div data-" + a.mobile.ns + "role='header'><div class='ui-title'>" + e.getEncodedText() + "</div></div><div data-" + a.mobile.ns + "role='content'></div></div>"),
                v = a("<div>", {
                    "class": "ui-selectmenu ui-selectmenu-hidden ui-overlay-shadow ui-corner-all ui-body-" + b.options.overlayTheme + " " + a.mobile.defaultDialogTransition
                }).insertAfter(f),
                n = a("<ul>", {
                    "class": "ui-selectmenu-list",
                    id: o,
                    role: "listbox",
                    "aria-labelledby": l
                }).attr("data-" + a.mobile.ns + "theme", b.options.theme).appendTo(v),
                r = a("<div>", {
                    "class": "ui-header ui-bar-" + b.options.theme
                }).prependTo(v),
                p = a("<h1>", {
                    "class": "ui-title"
                }).appendTo(r),
                s;
            b.isMultiple && (s = a("<a>", {
                text: b.options.closeText,
                href: "#",
                "class": "ui-btn-left"
            }).attr("data-" +
                a.mobile.ns + "iconpos", "notext").attr("data-" + a.mobile.ns + "icon", "delete").appendTo(r).buttonMarkup());
            a.extend(b, {
                select: b.select,
                selectID: c,
                buttonId: l,
                menuId: o,
                thisPage: g,
                menuPage: m,
                label: e,
                screen: f,
                selectOptions: j,
                isMultiple: h,
                theme: b.options.theme,
                listbox: v,
                list: n,
                header: r,
                headerTitle: p,
                headerClose: s,
                menuPageContent: void 0,
                menuPageClose: void 0,
                placeholder: "",
                build: function () {
                    var c = this;
                    c.refresh();
                    c.select.attr("tabindex", "-1").focus(function () {
                        a(this).blur();
                        c.button.focus()
                    });
                    c.button.bind("vclick keydown",
                        function (b) {
                            if (b.type == "vclick" || b.keyCode && (b.keyCode === a.mobile.keyCode.ENTER || b.keyCode === a.mobile.keyCode.SPACE)) c.open(), b.preventDefault()
                        });
                    c.list.attr("role", "listbox").bind("focusin", function (b) {
                        a(b.target).attr("tabindex", "0").trigger("vmouseover")
                    }).bind("focusout", function (b) {
                        a(b.target).attr("tabindex", "-1").trigger("vmouseout")
                    }).delegate("li:not(.ui-disabled, .ui-li-divider)", "click", function (d) {
                        var e = c.select[0].selectedIndex,
                            f = c.list.find("li:not(.ui-li-divider)").index(this),
                            h = c._selectOptions().eq(f)[0];
                        h.selected = c.isMultiple ? !h.selected : true;
                        c.isMultiple && a(this).find(".ui-icon").toggleClass("ui-icon-checkbox-on", h.selected).toggleClass("ui-icon-checkbox-off", !h.selected);
                        (c.isMultiple || e !== f) && c.select.trigger("change");
                        c.isMultiple ? c.list.find("li:not(.ui-li-divider)").eq(f).addClass("ui-btn-down-" + b.options.theme).find("a").first().focus() : c.close();
                        d.preventDefault()
                    }).keydown(function (c) {
                        var d = a(c.target),
                            e = d.closest("li");
                        switch (c.keyCode) {
                        case 38:
                            return c = e.prev().not(".ui-selectmenu-placeholder"),
                            c.is(".ui-li-divider") && (c = c.prev()), c.length && (d.blur().attr("tabindex", "-1"), c.addClass("ui-btn-down-" + b.options.theme).find("a").first().focus()), false;
                        case 40:
                            return c = e.next(), c.is(".ui-li-divider") && (c = c.next()), c.length && (d.blur().attr("tabindex", "-1"), c.addClass("ui-btn-down-" + b.options.theme).find("a").first().focus()), false;
                        case 13:
                        case 32:
                            return d.trigger("click"), false
                        }
                    });
                    c.menuPage.bind("pagehide", function () {
                        c.list.appendTo(c.listbox);
                        c._focusButton();
                        a.mobile._bindPageRemove.call(c.thisPage)
                    });
                    c.screen.bind("vclick", function () {
                        c.close()
                    });
                    c.isMultiple && c.headerClose.click(function () {
                        if (c.menuType == "overlay") return c.close(), false
                    });
                    c.thisPage.addDependents(this.menuPage)
                },
                _isRebuildRequired: function () {
                    var a = this.list.find("li");
                    return this._selectOptions().text() !== a.text()
                },
                selected: function () {
                    return this._selectOptions().filter(":selected:not(:jqmData(placeholder='true'))")
                },
                refresh: function (b) {
                    var c = this,
                        d;
                    (b || this._isRebuildRequired()) && c._buildList();
                    d = this.selectedIndices();
                    c.setButtonText();
                    c.setButtonCount();
                    c.list.find("li:not(.ui-li-divider)").removeClass(a.mobile.activeBtnClass).attr("aria-selected", false).each(function (b) {
                        a.inArray(b, d) > -1 && (b = a(this), b.attr("aria-selected", true), c.isMultiple ? b.find(".ui-icon").removeClass("ui-icon-checkbox-off").addClass("ui-icon-checkbox-on") : b.is(".ui-selectmenu-placeholder") ? b.next().addClass(a.mobile.activeBtnClass) : b.addClass(a.mobile.activeBtnClass))
                    })
                },
                close: function () {
                    if (!this.options.disabled && this.isOpen) this.menuType == "page" ? t.history.back() :
                        (this.screen.addClass("ui-screen-hidden"), this.listbox.addClass("ui-selectmenu-hidden").removeAttr("style").removeClass("in"), this.list.appendTo(this.listbox), this._focusButton()), this.isOpen = false
                },
                open: function () {
                    function c() {
                        var e = d.list.find("." + a.mobile.activeBtnClass + " a");
                        e.length === 0 && (e = d.list.find("li.ui-btn:not(:jqmData(placeholder='true')) a"));
                        e.first().focus().closest("li").addClass("ui-btn-down-" + b.options.theme)
                    }
                    if (!this.options.disabled) {
                        var d = this,
                            e = a(t),
                            f = d.list.parent(),
                            h = f.outerHeight(),
                            f = f.outerWidth();
                        a(".ui-page-active");
                        var g = e.scrollTop(),
                            j = d.button.offset().top,
                            l = e.height(),
                            e = e.width();
                        d.button.addClass(a.mobile.activeBtnClass);
                        setTimeout(function () {
                            d.button.removeClass(a.mobile.activeBtnClass)
                        }, 300);
                        if (0) {
                            d.menuPage.appendTo(a.mobile.pageContainer).page();
                            d.menuPageContent = m.find(".ui-content");
                            d.menuPageClose = m.find(".ui-header a");
                            d.thisPage.unbind("pagehide.remove");
                            if (g == 0 && j > l) d.thisPage.one("pagehide", function () {
                                a(this).jqmData("lastScroll",
                                    j)
                            });
                            d.menuPage.one("pageshow", function () {
                                c();
                                d.isOpen = true
                            });
                            d.menuType = "page";
                            d.menuPageContent.append(d.list);
                            d.menuPage.find("div .ui-title").text(d.label.text());
                            a.mobile.changePage(d.menuPage, {
                                transition: a.mobile.defaultDialogTransition
                            })
                        } else {
                            d.menuType = "overlay";
                            d.screen.height(a(k).height()).removeClass("ui-screen-hidden");
                            var n = j - g,
                                o = g + l - j,
                                q = h / 2,
                                p = parseFloat(d.list.parent().css("max-width")),
                                h = n > h / 2 && o > h / 2 ? j + d.button.outerHeight() / 2 - q : n > o ? g + l - h - 30 : g + 30;
                            f < p ? g = (e - f) / 2 : (g = d.button.offset().left +
                                d.button.outerWidth() / 2 - f / 2, g < 30 ? g = 30 : g + f > e && (g = e - f - 30));
                            d.listbox.append(d.list).removeClass("ui-selectmenu-hidden").css({
                                top: h,
                                left: g
                            }).addClass("in");
                            c();
                            d.isOpen = true
                        }
                    }
                },
                _buildList: function () {
                    var b = this.options,
                        c = this.placeholder,
                        d = true,
                        e = this.isMultiple ? "checkbox-off" : "false";
                    this.list.empty().filter(".ui-listview").listview("destroy");
                    var f = this.select.find("option"),
                        h = f.length,
                        g = this.select[0],
                        j = "data-" + a.mobile.ns,
                        l = j + "option-index",
                        m = j + "icon",
                        n = j + "role";
                    j += "placeholder";
                    for (var o = k.createDocumentFragment(),
                            q = false, p, t = 0; t < h; t++, q = false) {
                        var s = f[t],
                            r = a(s),
                            v = s.parentNode,
                            E = r.text(),
                            I = k.createElement("a"),
                            L = [];
                        I.setAttribute("href", "#");
                        I.appendChild(k.createTextNode(E));
                        v !== g && v.nodeName.toLowerCase() === "optgroup" && (v = v.getAttribute("label"), v != p && (p = k.createElement("li"), p.setAttribute(n, "list-divider"), p.setAttribute("role", "option"), p.setAttribute("tabindex", "-1"), p.appendChild(k.createTextNode(v)), o.appendChild(p), p = v));
                        if (d && (!s.getAttribute("value") || E.length == 0 || r.jqmData("placeholder")))
                            if (d =
                                false, q = true, s.setAttribute(j, true), b.hidePlaceholderMenuItems && L.push("ui-selectmenu-placeholder"), !c) c = this.placeholder = E;
                        r = k.createElement("li");
                        s.disabled && (L.push("ui-disabled"), r.setAttribute("aria-disabled", true));
                        r.setAttribute(l, t);
                        r.setAttribute(m, e);
                        q && r.setAttribute(j, true);
                        r.className = L.join(" ");
                        r.setAttribute("role", "option");
                        I.setAttribute("tabindex", "-1");
                        r.appendChild(I);
                        o.appendChild(r)
                    }
                    this.list[0].appendChild(o);
                    !this.isMultiple && !c.length ? this.header.hide() : this.headerTitle.text(this.placeholder);
                    this.list.listview()
                },
                _button: function () {
                    return a("<a>", {
                        href: "#",
                        role: "button",
                        id: this.buttonId,
                        "aria-haspopup": "true",
                        "aria-owns": this.menuId
                    })
                }
            })
        };
        a(k).bind("selectmenubeforecreate", function (b) {
            b = a(b.target).data("selectmenu");
            b.options.nativeMenu || c(b)
        })
    })(l);
    (function (a) {
        a.widget("mobile.fixedtoolbar", a.mobile.widget, {
            options: {
                visibleOnPageShow: true,
                disablePageZoom: true,
                transition: "slide",
                fullscreen: false,
                tapToggle: true,
                tapToggleBlacklist: "a, button, input, select, textarea, .ui-header-fixed, .ui-footer-fixed",
                hideDuringFocus: "input, textarea, select",
                updatePagePadding: true,
                trackPersistentToolbars: true,
                supportBlacklist: function () {
                    var a = navigator.userAgent,
                        b = navigator.platform,
                        d = a.match(/AppleWebKit\/([0-9]+)/),
                        d = !! d && d[1],
                        e = a.match(/Fennec\/([0-9]+)/),
                        e = !! e && e[1],
                        g = a.match(/Opera Mobi\/([0-9]+)/),
                        f = !! g && g[1];
                    return (b.indexOf("iPhone") > -1 || b.indexOf("iPad") > -1 || b.indexOf("iPod") > -1) && d && d < 534 || t.operamini && {}.toString.call(t.operamini) === "[object OperaMini]" || g && f < 7458 || a.indexOf("Android") > -1 && d && d < 533 ||
                        e && e < 6 || "palmGetResource" in t && d && d < 534 || a.indexOf("MeeGo") > -1 && a.indexOf("NokiaBrowser/8.5.0") > -1 ? true : false
                },
                initSelector: ":jqmData(position='fixed')"
            },
            _create: function () {
                var a = this.options,
                    b = this.element,
                    d = b.is(":jqmData(role='header')") ? "header" : "footer",
                    e = b.closest(".ui-page");
                a.supportBlacklist() ? this.destroy() : (b.addClass("ui-" + d + "-fixed"), a.fullscreen ? (b.addClass("ui-" + d + "-fullscreen"), e.addClass("ui-page-" + d + "-fullscreen")) : e.addClass("ui-page-" + d + "-fixed"), this._addTransitionClass(), this._bindPageEvents(),
                    this._bindToggleHandlers())
            },
            _addTransitionClass: function () {
                var a = this.options.transition;
                a && a !== "none" && (a === "slide" && (a = this.element.is(".ui-header") ? "slidedown" : "slideup"), this.element.addClass(a))
            },
            _bindPageEvents: function () {
                var c = this,
                    b = c.options;
                c.element.closest(".ui-page").bind("pagebeforeshow", function () {
                    b.disablePageZoom && a.mobile.zoom.disable(true);
                    b.visibleOnPageShow || c.hide(true)
                }).bind("webkitAnimationStart animationstart updatelayout", function () {
                    b.updatePagePadding && c.updatePagePadding(this)
                }).bind("pageshow",
                    function () {
                        var d = this;
                        c.updatePagePadding(d);
                        b.updatePagePadding && a(t).bind("throttledresize." + c.widgetName, function () {
                            c.updatePagePadding(d)
                        })
                    }).bind("pagebeforehide", function (d, e) {
                    b.disablePageZoom && a.mobile.zoom.enable(true);
                    b.updatePagePadding && a(t).unbind("throttledresize." + c.widgetName);
                    if (b.trackPersistentToolbars) {
                        var g = a(".ui-footer-fixed:jqmData(id)", this),
                            f = a(".ui-header-fixed:jqmData(id)", this),
                            j = g.length && e.nextPage && a(".ui-footer-fixed:jqmData(id='" + g.jqmData("id") + "')", e.nextPage),
                            h = f.length && e.nextPage && a(".ui-header-fixed:jqmData(id='" + f.jqmData("id") + "')", e.nextPage),
                            j = j || a();
                        if (j.length || h.length) j.add(h).appendTo(a.mobile.pageContainer), e.nextPage.one("pageshow", function () {
                            j.add(h).appendTo(this)
                        })
                    }
                })
            },
            _visible: true,
            updatePagePadding: function (c) {
                var b = this.element,
                    d = b.is(".ui-header");
                this.options.fullscreen || (c = c || b.closest(".ui-page"), a(c).css("padding-" + (d ? "top" : "bottom"), b.outerHeight()))
            },
            _useTransition: function (c) {
                var b = this.element,
                    d = a(t).scrollTop(),
                    e = b.height(),
                    g = b.closest(".ui-page").height(),
                    f = a.mobile.getScreenHeight(),
                    b = b.is(":jqmData(role='header')") ? "header" : "footer";
                return !c && (this.options.transition && this.options.transition !== "none" && (b === "header" && !this.options.fullscreen && d > e || b === "footer" && !this.options.fullscreen && d + f < g - e) || this.options.fullscreen)
            },
            show: function (a) {
                var b = this.element;
                this._useTransition(a) ? b.removeClass("out ui-fixed-hidden").addClass("in") : b.removeClass("ui-fixed-hidden");
                this._visible = true
            },
            hide: function (a) {
                var b = this.element,
                    d = "out" + (this.options.transition === "slide" ? " reverse" : "");
                this._useTransition(a) ? b.addClass(d).removeClass("in").animationComplete(function () {
                    b.addClass("ui-fixed-hidden").removeClass(d)
                }) : b.addClass("ui-fixed-hidden").removeClass(d);
                this._visible = false
            },
            toggle: function () {
                this[this._visible ? "hide" : "show"]()
            },
            _bindToggleHandlers: function () {
                var c = this,
                    b = c.options;
                c.element.closest(".ui-page").bind("vclick", function (d) {
                    b.tapToggle && !a(d.target).closest(b.tapToggleBlacklist).length && c.toggle()
                }).bind("focusin focusout",
                    function (d) {
                        if (screen.width < 500 && a(d.target).is(b.hideDuringFocus) && !a(d.target).closest(".ui-header-fixed, .ui-footer-fixed").length) c[d.type === "focusin" && c._visible ? "hide" : "show"]()
                    })
            },
            destroy: function () {
                this.element.removeClass("ui-header-fixed ui-footer-fixed ui-header-fullscreen ui-footer-fullscreen in out fade slidedown slideup ui-fixed-hidden");
                this.element.closest(".ui-page").removeClass("ui-page-header-fixed ui-page-footer-fixed ui-page-header-fullscreen ui-page-footer-fullscreen")
            }
        });
        a(k).bind("pagecreate create",
            function (c) {
                a(c.target).jqmData("fullscreen") && a(a.mobile.fixedtoolbar.prototype.options.initSelector, c.target).not(":jqmData(fullscreen)").jqmData("fullscreen", true);
                a.mobile.fixedtoolbar.prototype.enhanceWithin(c.target)
            })
    })(l);
    (function (a, c) {
        if (/iPhone|iPad|iPod/.test(navigator.platform) && navigator.userAgent.indexOf("AppleWebKit") > -1) {
            var b = a.mobile.zoom,
                d, e, g, f, j;
            a(c).bind("orientationchange.iosorientationfix", b.enable).bind("devicemotion.iosorientationfix", function (a) {
                d = a.originalEvent;
                j = d.accelerationIncludingGravity;
                e = Math.abs(j.x);
                g = Math.abs(j.y);
                f = Math.abs(j.z);
                !c.orientation && (e > 7 || (f > 6 && g < 8 || f < 8 && g > 6) && e > 5) ? b.enabled && b.disable() : b.enabled || b.enable()
            })
        }
    })(l, this);
    (function (a, c) {
        function b() {
            var b = a("." + a.mobile.activeBtnClass).first();
            j.css({
                top: a.support.scrollTop && f.scrollTop() + f.height() / 2 || b.length && b.offset().top || 100
            })
        }

        function d() {
            var c = j.offset(),
                e = f.scrollTop(),
                g = a.mobile.getScreenHeight();
            if (c.top < e || c.top - e > g) j.addClass("ui-loader-fakefix"), b(), f.unbind("scroll", d).bind("scroll", b)
        }

        function e() {
            g.removeClass("ui-mobile-rendering")
        }
        var g = a("html");
        a("head");
        var f = a(c);
        a(c.document).trigger("mobileinit");
        if (a.mobile.gradeA()) {
            if (a.mobile.ajaxBlacklist) a.mobile.ajaxEnabled = false;
            g.addClass("ui-mobile ui-mobile-rendering");
            setTimeout(e, 5E3);
            var j = a("<div class='ui-loader'><span class='ui-icon ui-icon-loading'></span><h1></h1></div>");
            a.extend(a.mobile, {
                showPageLoadingMsg: function (b, c, e) {
                    g.addClass("ui-loading");
                    if (a.mobile.loadingMessage) {
                        var k = e || a.mobile.loadingMessageTextVisible;
                        b = b || a.mobile.loadingMessageTheme;
                        j.attr("class",
                            "ui-loader ui-corner-all ui-body-" + (b || "a") + " ui-loader-" + (k ? "verbose" : "default") + (e ? " ui-loader-textonly" : "")).find("h1").text(c || a.mobile.loadingMessage).end().appendTo(a.mobile.pageContainer);
                        d();
                        f.bind("scroll", d)
                    }
                },
                hidePageLoadingMsg: function () {
                    g.removeClass("ui-loading");
                    a.mobile.loadingMessage && j.removeClass("ui-loader-fakefix");
                    a(c).unbind("scroll", b);
                    a(c).unbind("scroll", d)
                },
                initializePage: function () {
                    var b = a(":jqmData(role='page'), :jqmData(role='dialog')");
                    b.length || (b = a("body").wrapInner("<div data-" +
                        a.mobile.ns + "role='page'></div>").children(0));
                    b.each(function () {
                        var b = a(this);
                        b.jqmData("url") || b.attr("data-" + a.mobile.ns + "url", b.attr("id") || location.pathname + location.search)
                    });
                    a.mobile.firstPage = b.first();
                    a.mobile.pageContainer = b.first().parent().addClass("ui-mobile-viewport");
                    f.trigger("pagecontainercreate");
                    a.mobile.showPageLoadingMsg();
                    e();
                    !a.mobile.hashListeningEnabled || !a.mobile.path.isHashValid(location.hash) || !a(location.hash + ':jqmData(role="page")').length && !a.mobile.path.isPath(location.hash) ?
                        a.mobile.changePage(a.mobile.firstPage, {
                            transition: "none",
                            reverse: true,
                            changeHash: false,
                            fromHashChange: true
                        }) : f.trigger("hashchange", [true])
                }
            });
            a.mobile.navreadyDeferred.resolve();
            a(function () {
                c.scrollTo(0, 1);
                a.mobile.defaultHomeScroll = !a.support.scrollTop || a(c).scrollTop() === 1 ? 0 : 1;
                a.fn.controlgroup && a(k).bind("pagecreate create", function (b) {
                    a(":jqmData(role='controlgroup')", b.target).jqmEnhanceable().controlgroup({
                        excludeInvisible: false
                    })
                });
                a.mobile.autoInitializePage && a.mobile.initializePage();
                f.load(a.mobile.silentScroll);
                a.support.cssPointerEvents || a(k).delegate(".ui-disabled", "vclick", function (a) {
                    a.preventDefault();
                    a.stopImmediatePropagation()
                })
            })
        }
    })(l, this)
});
/**
 * jQuery Validation Plugin 1.9.0
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2011 Jörn Zaefferer
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function (c) {
    c.extend(c.fn, {
        validate: function (a) {
            if (this.length) {
                var b = c.data(this[0], "validator");
                if (b) return b;
                this.attr("novalidate", "novalidate");
                b = new c.validator(a, this[0]);
                c.data(this[0], "validator", b);
                if (b.settings.onsubmit) {
                    a = this.find("input, button");
                    a.filter(".cancel").click(function () {
                        b.cancelSubmit = true
                    });
                    b.settings.submitHandler && a.filter(":submit").click(function () {
                        b.submitButton = this
                    });
                    this.submit(function (d) {
                        function e() {
                            if (b.settings.submitHandler) {
                                if (b.submitButton) var f = c("<input type='hidden'/>").attr("name",
                                    b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);
                                b.settings.submitHandler.call(b, b.currentForm);
                                b.submitButton && f.remove();
                                return false
                            }
                            return true
                        }
                        b.settings.debug && d.preventDefault();
                        if (b.cancelSubmit) {
                            b.cancelSubmit = false;
                            return e()
                        }
                        if (b.form()) {
                            if (b.pendingRequest) {
                                b.formSubmitted = true;
                                return false
                            }
                            return e()
                        } else {
                            b.focusInvalid();
                            return false
                        }
                    })
                }
                return b
            } else a && a.debug && window.console && console.warn("nothing selected, can't validate, returning nothing")
        },
        valid: function () {
            if (c(this[0]).is("form")) return this.validate().form();
            else {
                var a = true,
                    b = c(this[0].form).validate();
                this.each(function () {
                    a &= b.element(this)
                });
                return a
            }
        },
        removeAttrs: function (a) {
            var b = {}, d = this;
            c.each(a.split(/\s/), function (e, f) {
                b[f] = d.attr(f);
                d.removeAttr(f)
            });
            return b
        },
        rules: function (a, b) {
            var d = this[0];
            if (a) {
                var e = c.data(d.form, "validator").settings,
                    f = e.rules,
                    g = c.validator.staticRules(d);
                switch (a) {
                case "add":
                    c.extend(g, c.validator.normalizeRule(b));
                    f[d.name] = g;
                    if (b.messages) e.messages[d.name] = c.extend(e.messages[d.name], b.messages);
                    break;
                case "remove":
                    if (!b) {
                        delete f[d.name];
                        return g
                    }
                    var h = {};
                    c.each(b.split(/\s/), function (j, i) {
                        h[i] = g[i];
                        delete g[i]
                    });
                    return h
                }
            }
            d = c.validator.normalizeRules(c.extend({}, c.validator.metadataRules(d), c.validator.classRules(d), c.validator.attributeRules(d), c.validator.staticRules(d)), d);
            if (d.required) {
                e = d.required;
                delete d.required;
                d = c.extend({
                    required: e
                }, d)
            }
            return d
        }
    });
    c.extend(c.expr[":"], {
        blank: function (a) {
            return !c.trim("" + a.value)
        },
        filled: function (a) {
            return !!c.trim("" + a.value)
        },
        unchecked: function (a) {
            return !a.checked
        }
    });
    c.validator = function (a,
        b) {
        this.settings = c.extend(true, {}, c.validator.defaults, a);
        this.currentForm = b;
        this.init()
    };
    c.validator.format = function (a, b) {
        if (arguments.length == 1) return function () {
            var d = c.makeArray(arguments);
            d.unshift(a);
            return c.validator.format.apply(this, d)
        };
        if (arguments.length > 2 && b.constructor != Array) b = c.makeArray(arguments).slice(1);
        if (b.constructor != Array) b = [b];
        c.each(b, function (d, e) {
            a = a.replace(RegExp("\\{" + d + "\\}", "g"), e)
        });
        return a
    };
    c.extend(c.validator, {
        defaults: {
            messages: {},
            groups: {},
            rules: {},
            errorClass: "error",
            validClass: "valid",
            errorElement: "label",
            focusInvalid: true,
            errorContainer: c([]),
            errorLabelContainer: c([]),
            onsubmit: true,
            ignore: ":hidden",
            ignoreTitle: false,
            onfocusin: function (a) {
                this.lastActive = a;
                if (this.settings.focusCleanup && !this.blockFocusCleanup) {
                    this.settings.unhighlight && this.settings.unhighlight.call(this, a, this.settings.errorClass, this.settings.validClass);
                    this.addWrapper(this.errorsFor(a)).hide()
                }
            },
            onfocusout: function (a) {
                if (!this.checkable(a) && (a.name in this.submitted || !this.optional(a))) this.element(a)
            },
            onkeyup: function (a) {
                if (a.name in this.submitted || a == this.lastElement) this.element(a)
            },
            onclick: function (a) {
                if (a.name in this.submitted) this.element(a);
                else a.parentNode.name in this.submitted && this.element(a.parentNode)
            },
            highlight: function (a, b, d) {
                a.type === "radio" ? this.findByName(a.name).addClass(b).removeClass(d) : c(a).addClass(b).removeClass(d)
            },
            unhighlight: function (a, b, d) {
                a.type === "radio" ? this.findByName(a.name).removeClass(b).addClass(d) : c(a).removeClass(b).addClass(d)
            }
        },
        setDefaults: function (a) {
            c.extend(c.validator.defaults,
                a)
        },
        messages: {
            required: "This field is required.",
            remote: "Please fix this field.",
            email: "Please enter a valid email address.",
            url: "Please enter a valid URL.",
            date: "Please enter a valid date.",
            dateISO: "Please enter a valid date (ISO).",
            number: "Please enter a valid number.",
            digits: "Please enter only digits.",
            creditcard: "Please enter a valid credit card number.",
            equalTo: "Please enter the same value again.",
            accept: "Please enter a value with a valid extension.",
            maxlength: c.validator.format("Please enter no more than {0} characters."),
            minlength: c.validator.format("Please enter at least {0} characters."),
            rangelength: c.validator.format("Please enter a value between {0} and {1} characters long."),
            range: c.validator.format("Please enter a value between {0} and {1}."),
            max: c.validator.format("Please enter a value less than or equal to {0}."),
            min: c.validator.format("Please enter a value greater than or equal to {0}.")
        },
        autoCreateRanges: false,
        prototype: {
            init: function () {
                function a(e) {
                    var f = c.data(this[0].form, "validator"),
                        g = "on" + e.type.replace(/^validate/,
                            "");
                    f.settings[g] && f.settings[g].call(f, this[0], e)
                }
                this.labelContainer = c(this.settings.errorLabelContainer);
                this.errorContext = this.labelContainer.length && this.labelContainer || c(this.currentForm);
                this.containers = c(this.settings.errorContainer).add(this.settings.errorLabelContainer);
                this.submitted = {};
                this.valueCache = {};
                this.pendingRequest = 0;
                this.pending = {};
                this.invalid = {};
                this.reset();
                var b = this.groups = {};
                c.each(this.settings.groups, function (e, f) {
                    c.each(f.split(/\s/), function (g, h) {
                        b[h] = e
                    })
                });
                var d =
                    this.settings.rules;
                c.each(d, function (e, f) {
                    d[e] = c.validator.normalizeRule(f)
                });
                c(this.currentForm).validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ", "focusin focusout keyup", a).validateDelegate("[type='radio'], [type='checkbox'], select, option", "click",
                    a);
                this.settings.invalidHandler && c(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler)
            },
            form: function () {
                this.checkForm();
                c.extend(this.submitted, this.errorMap);
                this.invalid = c.extend({}, this.errorMap);
                this.valid() || c(this.currentForm).triggerHandler("invalid-form", [this]);
                this.showErrors();
                return this.valid()
            },
            checkForm: function () {
                this.prepareForm();
                for (var a = 0, b = this.currentElements = this.elements(); b[a]; a++) this.check(b[a]);
                return this.valid()
            },
            element: function (a) {
                this.lastElement =
                    a = this.validationTargetFor(this.clean(a));
                this.prepareElement(a);
                this.currentElements = c(a);
                var b = this.check(a);
                if (b) delete this.invalid[a.name];
                else this.invalid[a.name] = true; if (!this.numberOfInvalids()) this.toHide = this.toHide.add(this.containers);
                this.showErrors();
                return b
            },
            showErrors: function (a) {
                if (a) {
                    c.extend(this.errorMap, a);
                    this.errorList = [];
                    for (var b in a) this.errorList.push({
                        message: a[b],
                        element: this.findByName(b)[0]
                    });
                    this.successList = c.grep(this.successList, function (d) {
                        return !(d.name in a)
                    })
                }
                this.settings.showErrors ?
                    this.settings.showErrors.call(this, this.errorMap, this.errorList) : this.defaultShowErrors()
            },
            resetForm: function () {
                c.fn.resetForm && c(this.currentForm).resetForm();
                this.submitted = {};
                this.lastElement = null;
                this.prepareForm();
                this.hideErrors();
                this.elements().removeClass(this.settings.errorClass)
            },
            numberOfInvalids: function () {
                return this.objectLength(this.invalid)
            },
            objectLength: function (a) {
                var b = 0,
                    d;
                for (d in a) b++;
                return b
            },
            hideErrors: function () {
                this.addWrapper(this.toHide).hide()
            },
            valid: function () {
                return this.size() ==
                    0
            },
            size: function () {
                return this.errorList.length
            },
            focusInvalid: function () {
                if (this.settings.focusInvalid) try {
                    c(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus().trigger("focusin")
                } catch (a) {}
            },
            findLastActive: function () {
                var a = this.lastActive;
                return a && c.grep(this.errorList, function (b) {
                    return b.element.name == a.name
                }).length == 1 && a
            },
            elements: function () {
                var a = this,
                    b = {};
                return c(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function () {
                    !this.name &&
                        a.settings.debug && window.console && console.error("%o has no name assigned", this);
                    if (this.name in b || !a.objectLength(c(this).rules())) return false;
                    return b[this.name] = true
                })
            },
            clean: function (a) {
                return c(a)[0]
            },
            errors: function () {
                return c(this.settings.errorElement + "." + this.settings.errorClass, this.errorContext)
            },
            reset: function () {
                this.successList = [];
                this.errorList = [];
                this.errorMap = {};
                this.toShow = c([]);
                this.toHide = c([]);
                this.currentElements = c([])
            },
            prepareForm: function () {
                this.reset();
                this.toHide = this.errors().add(this.containers)
            },
            prepareElement: function (a) {
                this.reset();
                this.toHide = this.errorsFor(a)
            },
            check: function (a) {
                a = this.validationTargetFor(this.clean(a));
                var b = c(a).rules(),
                    d = false,
                    e;
                for (e in b) {
                    var f = {
                        method: e,
                        parameters: b[e]
                    };
                    try {
                        var g = c.validator.methods[e].call(this, a.value.replace(/\r/g, ""), a, f.parameters);
                        if (g == "dependency-mismatch") d = true;
                        else {
                            d = false;
                            if (g == "pending") {
                                this.toHide = this.toHide.not(this.errorsFor(a));
                                return
                            }
                            if (!g) {
                                this.formatAndAdd(a, f);
                                return false
                            }
                        }
                    } catch (h) {
                        this.settings.debug && window.console && console.log("exception occured when checking element " +
                            a.id + ", check the '" + f.method + "' method", h);
                        throw h;
                    }
                }
                if (!d) {
                    this.objectLength(b) && this.successList.push(a);
                    return true
                }
            },
            customMetaMessage: function (a, b) {
                if (c.metadata) {
                    var d = this.settings.meta ? c(a).metadata()[this.settings.meta] : c(a).metadata();
                    return d && d.messages && d.messages[b]
                }
            },
            customMessage: function (a, b) {
                var d = this.settings.messages[a];
                return d && (d.constructor == String ? d : d[b])
            },
            findDefined: function () {
                for (var a = 0; a < arguments.length; a++)
                    if (arguments[a] !== undefined) return arguments[a]
            },
            defaultMessage: function (a,
                b) {
                return this.findDefined(this.customMessage(a.name, b), this.customMetaMessage(a, b), !this.settings.ignoreTitle && a.title || undefined, c.validator.messages[b], "<strong>Warning: No message defined for " + a.name + "</strong>")
            },
            formatAndAdd: function (a, b) {
                var d = this.defaultMessage(a, b.method),
                    e = /\$?\{(\d+)\}/g;
                if (typeof d == "function") d = d.call(this, b.parameters, a);
                else if (e.test(d)) d = jQuery.format(d.replace(e, "{$1}"), b.parameters);
                this.errorList.push({
                    message: d,
                    element: a
                });
                this.errorMap[a.name] = d;
                this.submitted[a.name] =
                    d
            },
            addWrapper: function (a) {
                if (this.settings.wrapper) a = a.add(a.parent(this.settings.wrapper));
                return a
            },
            defaultShowErrors: function () {
                for (var a = 0; this.errorList[a]; a++) {
                    var b = this.errorList[a];
                    this.settings.highlight && this.settings.highlight.call(this, b.element, this.settings.errorClass, this.settings.validClass);
                    this.showLabel(b.element, b.message)
                }
                if (this.errorList.length) this.toShow = this.toShow.add(this.containers);
                if (this.settings.success)
                    for (a = 0; this.successList[a]; a++) this.showLabel(this.successList[a]);
                if (this.settings.unhighlight) {
                    a = 0;
                    for (b = this.validElements(); b[a]; a++) this.settings.unhighlight.call(this, b[a], this.settings.errorClass, this.settings.validClass)
                }
                this.toHide = this.toHide.not(this.toShow);
                this.hideErrors();
                this.addWrapper(this.toShow).show()
            },
            validElements: function () {
                return this.currentElements.not(this.invalidElements())
            },
            invalidElements: function () {
                return c(this.errorList).map(function () {
                    return this.element
                })
            },
            showLabel: function (a, b) {
                var d = this.errorsFor(a);
                if (d.length) {
                    d.removeClass(this.settings.validClass).addClass(this.settings.errorClass);
                    d.attr("generated") && d.html(b)
                } else {
                    d = c("<" + this.settings.errorElement + "/>").attr({
                        "for": this.idOrName(a),
                        generated: true
                    }).addClass(this.settings.errorClass).html(b || "");
                    if (this.settings.wrapper) d = d.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
                    this.labelContainer.append(d).length || (this.settings.errorPlacement ? this.settings.errorPlacement(d, c(a)) : d.insertAfter(a))
                } if (!b && this.settings.success) {
                    d.text("");
                    typeof this.settings.success == "string" ? d.addClass(this.settings.success) : this.settings.success(d)
                }
                this.toShow =
                    this.toShow.add(d)
            },
            errorsFor: function (a) {
                var b = this.idOrName(a);
                return this.errors().filter(function () {
                    return c(this).attr("for") == b
                })
            },
            idOrName: function (a) {
                return this.groups[a.name] || (this.checkable(a) ? a.name : a.id || a.name)
            },
            validationTargetFor: function (a) {
                if (this.checkable(a)) a = this.findByName(a.name).not(this.settings.ignore)[0];
                return a
            },
            checkable: function (a) {
                return /radio|checkbox/i.test(a.type)
            },
            findByName: function (a) {
                var b = this.currentForm;
                return c(document.getElementsByName(a)).map(function (d,
                    e) {
                    return e.form == b && e.name == a && e || null
                })
            },
            getLength: function (a, b) {
                switch (b.nodeName.toLowerCase()) {
                case "select":
                    return c("option:selected", b).length;
                case "input":
                    if (this.checkable(b)) return this.findByName(b.name).filter(":checked").length
                }
                return a.length
            },
            depend: function (a, b) {
                return this.dependTypes[typeof a] ? this.dependTypes[typeof a](a, b) : true
            },
            dependTypes: {
                "boolean": function (a) {
                    return a
                },
                string: function (a, b) {
                    return !!c(a, b.form).length
                },
                "function": function (a, b) {
                    return a(b)
                }
            },
            optional: function (a) {
                return !c.validator.methods.required.call(this,
                    c.trim(a.value), a) && "dependency-mismatch"
            },
            startRequest: function (a) {
                if (!this.pending[a.name]) {
                    this.pendingRequest++;
                    this.pending[a.name] = true
                }
            },
            stopRequest: function (a, b) {
                this.pendingRequest--;
                if (this.pendingRequest < 0) this.pendingRequest = 0;
                delete this.pending[a.name];
                if (b && this.pendingRequest == 0 && this.formSubmitted && this.form()) {
                    c(this.currentForm).submit();
                    this.formSubmitted = false
                } else if (!b && this.pendingRequest == 0 && this.formSubmitted) {
                    c(this.currentForm).triggerHandler("invalid-form", [this]);
                    this.formSubmitted =
                        false
                }
            },
            previousValue: function (a) {
                return c.data(a, "previousValue") || c.data(a, "previousValue", {
                    old: null,
                    valid: true,
                    message: this.defaultMessage(a, "remote")
                })
            }
        },
        classRuleSettings: {
            required: {
                required: true
            },
            email: {
                email: true
            },
            url: {
                url: true
            },
            date: {
                date: true
            },
            dateISO: {
                dateISO: true
            },
            dateDE: {
                dateDE: true
            },
            number: {
                number: true
            },
            numberDE: {
                numberDE: true
            },
            digits: {
                digits: true
            },
            creditcard: {
                creditcard: true
            }
        },
        addClassRules: function (a, b) {
            a.constructor == String ? this.classRuleSettings[a] = b : c.extend(this.classRuleSettings,
                a)
        },
        classRules: function (a) {
            var b = {};
            (a = c(a).attr("class")) && c.each(a.split(" "), function () {
                this in c.validator.classRuleSettings && c.extend(b, c.validator.classRuleSettings[this])
            });
            return b
        },
        attributeRules: function (a) {
            var b = {};
            a = c(a);
            for (var d in c.validator.methods) {
                var e;
                if (e = d === "required" && typeof c.fn.prop === "function" ? a.prop(d) : a.attr(d)) b[d] = e;
                else if (a[0].getAttribute("type") === d) b[d] = true
            }
            b.maxlength && /-1|2147483647|524288/.test(b.maxlength) && delete b.maxlength;
            return b
        },
        metadataRules: function (a) {
            if (!c.metadata) return {};
            var b = c.data(a.form, "validator").settings.meta;
            return b ? c(a).metadata()[b] : c(a).metadata()
        },
        staticRules: function (a) {
            var b = {}, d = c.data(a.form, "validator");
            if (d.settings.rules) b = c.validator.normalizeRule(d.settings.rules[a.name]) || {};
            return b
        },
        normalizeRules: function (a, b) {
            c.each(a, function (d, e) {
                if (e === false) delete a[d];
                else if (e.param || e.depends) {
                    var f = true;
                    switch (typeof e.depends) {
                    case "string":
                        f = !! c(e.depends, b.form).length;
                        break;
                    case "function":
                        f = e.depends.call(b, b)
                    }
                    if (f) a[d] = e.param !== undefined ?
                        e.param : true;
                    else delete a[d]
                }
            });
            c.each(a, function (d, e) {
                a[d] = c.isFunction(e) ? e(b) : e
            });
            c.each(["minlength", "maxlength", "min", "max"], function () {
                if (a[this]) a[this] = Number(a[this])
            });
            c.each(["rangelength", "range"], function () {
                if (a[this]) a[this] = [Number(a[this][0]), Number(a[this][1])]
            });
            if (c.validator.autoCreateRanges) {
                if (a.min && a.max) {
                    a.range = [a.min, a.max];
                    delete a.min;
                    delete a.max
                }
                if (a.minlength && a.maxlength) {
                    a.rangelength = [a.minlength, a.maxlength];
                    delete a.minlength;
                    delete a.maxlength
                }
            }
            a.messages && delete a.messages;
            return a
        },
        normalizeRule: function (a) {
            if (typeof a == "string") {
                var b = {};
                c.each(a.split(/\s/), function () {
                    b[this] = true
                });
                a = b
            }
            return a
        },
        addMethod: function (a, b, d) {
            c.validator.methods[a] = b;
            c.validator.messages[a] = d != undefined ? d : c.validator.messages[a];
            b.length < 3 && c.validator.addClassRules(a, c.validator.normalizeRule(a))
        },
        methods: {
            required: function (a, b, d) {
                if (!this.depend(d, b)) return "dependency-mismatch";
                switch (b.nodeName.toLowerCase()) {
                case "select":
                    return (a = c(b).val()) && a.length > 0;
                case "input":
                    if (this.checkable(b)) return this.getLength(a,
                        b) > 0;
                default:
                    return c.trim(a).length > 0
                }
            },
            remote: function (a, b, d) {
                if (this.optional(b)) return "dependency-mismatch";
                var e = this.previousValue(b);
                this.settings.messages[b.name] || (this.settings.messages[b.name] = {});
                e.originalMessage = this.settings.messages[b.name].remote;
                this.settings.messages[b.name].remote = e.message;
                d = typeof d == "string" && {
                    url: d
                } || d;
                if (this.pending[b.name]) return "pending";
                if (e.old === a) return e.valid;
                e.old = a;
                var f = this;
                this.startRequest(b);
                var g = {};
                g[b.name] = a;
                c.ajax(c.extend(true, {
                    url: d,
                    mode: "abort",
                    port: "validate" + b.name,
                    dataType: "json",
                    data: g,
                    success: function (h) {
                        f.settings.messages[b.name].remote = e.originalMessage;
                        var j = h === true;
                        if (j) {
                            var i = f.formSubmitted;
                            f.prepareElement(b);
                            f.formSubmitted = i;
                            f.successList.push(b);
                            f.showErrors()
                        } else {
                            i = {};
                            h = h || f.defaultMessage(b, "remote");
                            i[b.name] = e.message = c.isFunction(h) ? h(a) : h;
                            f.showErrors(i)
                        }
                        e.valid = j;
                        f.stopRequest(b, j)
                    }
                }, d));
                return "pending"
            },
            minlength: function (a, b, d) {
                return this.optional(b) || this.getLength(c.trim(a), b) >= d
            },
            maxlength: function (a,
                b, d) {
                return this.optional(b) || this.getLength(c.trim(a), b) <= d
            },
            rangelength: function (a, b, d) {
                a = this.getLength(c.trim(a), b);
                return this.optional(b) || a >= d[0] && a <= d[1]
            },
            min: function (a, b, d) {
                return this.optional(b) || a >= d
            },
            max: function (a, b, d) {
                return this.optional(b) || a <= d
            },
            range: function (a, b, d) {
                return this.optional(b) || a >= d[0] && a <= d[1]
            },
            email: function (a, b) {
                return this.optional(b) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(a)
            },
            url: function (a, b) {
                return this.optional(b) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)
            },
            date: function (a, b) {
                return this.optional(b) || !/Invalid|NaN/.test(new Date(a))
            },
            dateISO: function (a, b) {
                return this.optional(b) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)
            },
            number: function (a, b) {
                return this.optional(b) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)
            },
            digits: function (a, b) {
                return this.optional(b) || /^\d+$/.test(a)
            },
            creditcard: function (a, b) {
                if (this.optional(b)) return "dependency-mismatch";
                if (/[^0-9 -]+/.test(a)) return false;
                var d = 0,
                    e = 0,
                    f = false;
                a = a.replace(/\D/g, "");
                for (var g = a.length - 1; g >=
                    0; g--) {
                    e = a.charAt(g);
                    e = parseInt(e, 10);
                    if (f)
                        if ((e *= 2) > 9) e -= 9;
                    d += e;
                    f = !f
                }
                return d % 10 == 0
            },
            accept: function (a, b, d) {
                d = typeof d == "string" ? d.replace(/,/g, "|") : "png|jpe?g|gif";
                return this.optional(b) || a.match(RegExp(".(" + d + ")$", "i"))
            },
            equalTo: function (a, b, d) {
                d = c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo", function () {
                    c(b).valid()
                });
                return a == d.val()
            }
        }
    });
    c.format = c.validator.format
})(jQuery);
(function (c) {
    var a = {};
    if (c.ajaxPrefilter) c.ajaxPrefilter(function (d, e, f) {
        e = d.port;
        if (d.mode == "abort") {
            a[e] && a[e].abort();
            a[e] = f
        }
    });
    else {
        var b = c.ajax;
        c.ajax = function (d) {
            var e = ("port" in d ? d : c.ajaxSettings).port;
            if (("mode" in d ? d : c.ajaxSettings).mode == "abort") {
                a[e] && a[e].abort();
                return a[e] = b.apply(this, arguments)
            }
            return b.apply(this, arguments)
        }
    }
})(jQuery);
(function (c) {
    !jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener && c.each({
        focus: "focusin",
        blur: "focusout"
    }, function (a, b) {
        function d(e) {
            e = c.event.fix(e);
            e.type = b;
            return c.event.handle.call(this, e)
        }
        c.event.special[b] = {
            setup: function () {
                this.addEventListener(a, d, true)
            },
            teardown: function () {
                this.removeEventListener(a, d, true)
            },
            handler: function (e) {
                arguments[0] = c.event.fix(e);
                arguments[0].type = b;
                return c.event.handle.apply(this, arguments)
            }
        }
    });
    c.extend(c.fn, {
        validateDelegate: function (a,
            b, d) {
            return this.bind(b, function (e) {
                var f = c(e.target);
                if (f.is(a)) return d.apply(f, arguments)
            })
        }
    })
})(jQuery);

(function ($) {
    jQuery.validator.setDefaults({
        errorPlacement: function (label, element) {
            var tag = element[0].tagName.toUpperCase();
            if (tag == 'SELECT') {
                label.appendTo(element.closest('.ui-select'));
                return;
            } else if (tag == 'INPUT') {
                var type = element[0].type.toLowerCase();
                if (type == 'checkbox' || type == 'radio') {
                    var container = element.closest('.ui-controlgroup-controls');
                    if (container.length > 0) {
                        label.appendTo(container);
                        return;
                    } else {
                        container = element.closest('.ui-' + type);
                        if (container.length > 0) {
                            label.insertAfter(container);
                            return;
                        }
                    }
                }
            }
            label.insertAfter(element);
        }
    });
})(jQuery);
(function () {
    function r(a, c, d) {
        if (a === c) return 0 !== a || 1 / a == 1 / c;
        if (null == a || null == c) return a === c;
        a._chain && (a = a._wrapped);
        c._chain && (c = c._wrapped);
        if (a.isEqual && b.isFunction(a.isEqual)) return a.isEqual(c);
        if (c.isEqual && b.isFunction(c.isEqual)) return c.isEqual(a);
        var e = l.call(a);
        if (e != l.call(c)) return !1;
        switch (e) {
        case "[object String]":
            return a == "" + c;
        case "[object Number]":
            return a != +a ? c != +c : 0 == a ? 1 / a == 1 / c : a == +c;
        case "[object Date]":
        case "[object Boolean]":
            return +a == +c;
        case "[object RegExp]":
            return a.source == c.source && a.global == c.global && a.multiline == c.multiline && a.ignoreCase == c.ignoreCase
        }
        if ("object" != typeof a || "object" != typeof c) return !1;
        for (var f = d.length; f--;)
            if (d[f] == a) return !0;
        d.push(a);
        var f = 0,
            g = !0;
        if ("[object Array]" == e) {
            if (f = a.length, g = f == c.length)
                for (; f-- && (g = f in a == f in c && r(a[f], c[f], d)););
        } else {
            if ("constructor" in a != "constructor" in c || a.constructor != c.constructor) return !1;
            for (var h in a)
                if (b.has(a, h) && (f++, !(g = b.has(c, h) && r(a[h], c[h], d)))) break;
            if (g) {
                for (h in c)
                    if (b.has(c, h) && !f--) break;
                g = !f
            }
        }
        d.pop();
        return g
    }
    var s = this,
        I = s._,
        o = {}, k = Array.prototype,
        p = Object.prototype,
        i = k.slice,
        J = k.unshift,
        l = p.toString,
        K = p.hasOwnProperty,
        y = k.forEach,
        z = k.map,
        A = k.reduce,
        B = k.reduceRight,
        C = k.filter,
        D = k.every,
        E = k.some,
        q = k.indexOf,
        F = k.lastIndexOf,
        p = Array.isArray,
        L = Object.keys,
        t = Function.prototype.bind,
        b = function (a) {
            return new m(a)
        };
    "undefined" !== typeof exports ? ("undefined" !== typeof module && module.exports && (exports = module.exports = b), exports._ = b) : s._ = b;
    b.VERSION = "1.3.3";
    var j = b.each = b.forEach = function (a, c, d) {
        if (a != null)
            if (y && a.forEach === y) a.forEach(c, d);
            else if (a.length === +a.length)
            for (var e = 0, f = a.length; e < f; e++) {
                if (e in a && c.call(d, a[e], e, a) === o) break
            } else
                for (e in a)
                    if (b.has(a, e) && c.call(d, a[e], e, a) === o) break
    };
    b.map = b.collect = function (a, c, b) {
        var e = [];
        if (a == null) return e;
        if (z && a.map === z) return a.map(c, b);
        j(a, function (a, g, h) {
            e[e.length] = c.call(b, a, g, h)
        });
        if (a.length === +a.length) e.length = a.length;
        return e
    };
    b.reduce = b.foldl = b.inject = function (a, c, d, e) {
        var f = arguments.length > 2;
        a == null && (a = []);
        if (A && a.reduce === A) {
            e && (c = b.bind(c, e));
            return f ? a.reduce(c, d) : a.reduce(c)
        }
        j(a, function (a, b, i) {
            if (f) d = c.call(e, d, a, b, i);
            else {
                d = a;
                f = true
            }
        });
        if (!f) throw new TypeError("Reduce of empty array with no initial value");
        return d
    };
    b.reduceRight = b.foldr = function (a, c, d, e) {
        var f = arguments.length > 2;
        a == null && (a = []);
        if (B && a.reduceRight === B) {
            e && (c = b.bind(c, e));
            return f ? a.reduceRight(c, d) : a.reduceRight(c)
        }
        var g = b.toArray(a).reverse();
        e && !f && (c = b.bind(c, e));
        return f ? b.reduce(g, c, d, e) : b.reduce(g, c)
    };
    b.find = b.detect = function (a, c, b) {
        var e;
        G(a, function (a, g, h) {
            if (c.call(b, a, g, h)) {
                e = a;
                return true
            }
        });
        return e
    };
    b.filter = b.select = function (a, c, b) {
        var e = [];
        if (a == null) return e;
        if (C && a.filter === C) return a.filter(c, b);
        j(a, function (a, g, h) {
            c.call(b, a, g, h) && (e[e.length] = a)
        });
        return e
    };
    b.reject = function (a, c, b) {
        var e = [];
        if (a == null) return e;
        j(a, function (a, g, h) {
            c.call(b, a, g, h) || (e[e.length] = a)
        });
        return e
    };
    b.every = b.all = function (a, c, b) {
        var e = true;
        if (a == null) return e;
        if (D && a.every === D) return a.every(c, b);
        j(a, function (a, g, h) {
            if (!(e = e && c.call(b, a, g, h))) return o
        });
        return !!e
    };
    var G = b.some = b.any = function (a, c, d) {
        c || (c = b.identity);
        var e = false;
        if (a == null) return e;
        if (E && a.some === E) return a.some(c, d);
        j(a, function (a, b, h) {
            if (e || (e = c.call(d, a, b, h))) return o
        });
        return !!e
    };
    b.include = b.contains = function (a, c) {
        var b = false;
        if (a == null) return b;
        if (q && a.indexOf === q) return a.indexOf(c) != -1;
        return b = G(a, function (a) {
            return a === c
        })
    };
    b.invoke = function (a, c) {
        var d = i.call(arguments, 2);
        return b.map(a, function (a) {
            return (b.isFunction(c) ? c || a : a[c]).apply(a, d)
        })
    };
    b.pluck = function (a, c) {
        return b.map(a, function (a) {
            return a[c]
        })
    };
    b.max = function (a, c, d) {
        if (!c && b.isArray(a) && a[0] === +a[0]) return Math.max.apply(Math, a);
        if (!c && b.isEmpty(a)) return -Infinity;
        var e = {
            computed: -Infinity
        };
        j(a, function (a, b, h) {
            b = c ? c.call(d, a, b, h) : a;
            b >= e.computed && (e = {
                value: a,
                computed: b
            })
        });
        return e.value
    };
    b.min = function (a, c, d) {
        if (!c && b.isArray(a) && a[0] === +a[0]) return Math.min.apply(Math, a);
        if (!c && b.isEmpty(a)) return Infinity;
        var e = {
            computed: Infinity
        };
        j(a, function (a, b, h) {
            b = c ? c.call(d, a, b, h) : a;
            b < e.computed && (e = {
                value: a,
                computed: b
            })
        });
        return e.value
    };
    b.shuffle = function (a) {
        var b = [],
            d;
        j(a, function (a, f) {
            d = Math.floor(Math.random() * (f + 1));
            b[f] = b[d];
            b[d] = a
        });
        return b
    };
    b.sortBy = function (a, c, d) {
        var e = b.isFunction(c) ? c : function (a) {
                return a[c]
            };
        return b.pluck(b.map(a, function (a, b, c) {
            return {
                value: a,
                criteria: e.call(d, a, b, c)
            }
        }).sort(function (a, b) {
            var c = a.criteria,
                d = b.criteria;
            return c === void 0 ? 1 : d === void 0 ? -1 : c < d ? -1 : c > d ? 1 : 0
        }), "value")
    };
    b.groupBy = function (a, c) {
        var d = {}, e = b.isFunction(c) ? c : function (a) {
                return a[c]
            };
        j(a, function (a, b) {
            var c = e(a, b);
            (d[c] || (d[c] = [])).push(a)
        });
        return d
    };
    b.sortedIndex = function (a, c, d) {
        d || (d = b.identity);
        for (var e = 0, f = a.length; e < f;) {
            var g = e + f >> 1;
            d(a[g]) < d(c) ? e = g + 1 : f = g
        }
        return e
    };
    b.toArray = function (a) {
        return !a ? [] : b.isArray(a) || b.isArguments(a) ? i.call(a) : a.toArray && b.isFunction(a.toArray) ? a.toArray() : b.values(a)
    };
    b.size = function (a) {
        return b.isArray(a) ? a.length : b.keys(a).length
    };
    b.first = b.head = b.take = function (a, b, d) {
        return b != null && !d ? i.call(a, 0, b) : a[0]
    };
    b.initial = function (a, b, d) {
        return i.call(a, 0, a.length - (b == null || d ? 1 : b))
    };
    b.last = function (a, b, d) {
        return b != null && !d ? i.call(a, Math.max(a.length - b, 0)) : a[a.length - 1]
    };
    b.rest = b.tail = function (a, b, d) {
        return i.call(a, b == null || d ? 1 : b)
    };
    b.compact = function (a) {
        return b.filter(a, function (a) {
            return !!a
        })
    };
    b.flatten = function (a, c) {
        return b.reduce(a, function (a, e) {
            if (b.isArray(e)) return a.concat(c ? e : b.flatten(e));
            a[a.length] = e;
            return a
        }, [])
    };
    b.without = function (a) {
        return b.difference(a, i.call(arguments, 1))
    };
    b.uniq = b.unique = function (a, c, d) {
        var d = d ? b.map(a, d) : a,
            e = [];
        a.length < 3 && (c = true);
        b.reduce(d, function (d, g, h) {
            if (c ? b.last(d) !== g || !d.length : !b.include(d, g)) {
                d.push(g);
                e.push(a[h])
            }
            return d
        }, []);
        return e
    };
    b.union = function () {
        return b.uniq(b.flatten(arguments, true))
    };
    b.intersection = b.intersect = function (a) {
        var c = i.call(arguments, 1);
        return b.filter(b.uniq(a), function (a) {
            return b.every(c, function (c) {
                return b.indexOf(c, a) >= 0
            })
        })
    };
    b.difference = function (a) {
        var c = b.flatten(i.call(arguments, 1), true);
        return b.filter(a, function (a) {
            return !b.include(c, a)
        })
    };
    b.zip = function () {
        for (var a = i.call(arguments), c = b.max(b.pluck(a, "length")), d = Array(c), e = 0; e < c; e++) d[e] = b.pluck(a, "" + e);
        return d
    };
    b.indexOf = function (a, c, d) {
        if (a == null) return -1;
        var e;
        if (d) {
            d = b.sortedIndex(a, c);
            return a[d] === c ? d : -1
        }
        if (q && a.indexOf === q) return a.indexOf(c);
        d = 0;
        for (e = a.length; d < e; d++)
            if (d in a && a[d] === c) return d;
        return -1
    };
    b.lastIndexOf = function (a, b) {
        if (a == null) return -1;
        if (F && a.lastIndexOf === F) return a.lastIndexOf(b);
        for (var d = a.length; d--;)
            if (d in a && a[d] === b) return d;
        return -1
    };
    b.range = function (a, b, d) {
        if (arguments.length <= 1) {
            b = a || 0;
            a = 0
        }
        for (var d = arguments[2] || 1, e = Math.max(Math.ceil((b - a) / d), 0), f = 0, g = Array(e); f < e;) {
            g[f++] = a;
            a = a + d
        }
        return g
    };
    var H = function () {};
    b.bind = function (a, c) {
        var d, e;
        if (a.bind === t && t) return t.apply(a, i.call(arguments, 1));
        if (!b.isFunction(a)) throw new TypeError;
        e = i.call(arguments, 2);
        return d = function () {
            if (!(this instanceof d)) return a.apply(c, e.concat(i.call(arguments)));
            H.prototype = a.prototype;
            var b = new H,
                g = a.apply(b, e.concat(i.call(arguments)));
            return Object(g) === g ? g : b
        }
    };
    b.bindAll = function (a) {
        var c = i.call(arguments, 1);
        c.length == 0 && (c = b.functions(a));
        j(c, function (c) {
            a[c] = b.bind(a[c], a)
        });
        return a
    };
    b.memoize = function (a, c) {
        var d = {};
        c || (c = b.identity);
        return function () {
            var e = c.apply(this, arguments);
            return b.has(d, e) ? d[e] : d[e] = a.apply(this, arguments)
        }
    };
    b.delay = function (a, b) {
        var d = i.call(arguments, 2);
        return setTimeout(function () {
            return a.apply(null, d)
        }, b)
    };
    b.defer = function (a) {
        return b.delay.apply(b, [a, 1].concat(i.call(arguments, 1)))
    };
    b.throttle = function (a, c) {
        var d, e, f, g, h, i, j = b.debounce(function () {
                h = g = false
            }, c);
        return function () {
            d = this;
            e = arguments;
            f || (f = setTimeout(function () {
                f = null;
                h && a.apply(d, e);
                j()
            }, c));
            g ? h = true : i = a.apply(d, e);
            j();
            g = true;
            return i
        }
    };
    b.debounce = function (a, b, d) {
        var e;
        return function () {
            var f = this,
                g = arguments;
            d && !e && a.apply(f, g);
            clearTimeout(e);
            e = setTimeout(function () {
                e = null;
                d || a.apply(f, g)
            }, b)
        }
    };
    b.once = function (a) {
        var b = false,
            d;
        return function () {
            if (b) return d;
            b = true;
            return d = a.apply(this, arguments)
        }
    };
    b.wrap = function (a, b) {
        return function () {
            var d = [a].concat(i.call(arguments, 0));
            return b.apply(this, d)
        }
    };
    b.compose = function () {
        var a = arguments;
        return function () {
            for (var b = arguments, d = a.length - 1; d >= 0; d--) b = [a[d].apply(this, b)];
            return b[0]
        }
    };
    b.after = function (a, b) {
        return a <= 0 ? b() : function () {
            if (--a < 1) return b.apply(this, arguments)
        }
    };
    b.keys = L || function (a) {
        if (a !== Object(a)) throw new TypeError("Invalid object");
        var c = [],
            d;
        for (d in a) b.has(a, d) && (c[c.length] = d);
        return c
    };
    b.values = function (a) {
        return b.map(a, b.identity)
    };
    b.functions = b.methods = function (a) {
        var c = [],
            d;
        for (d in a) b.isFunction(a[d]) && c.push(d);
        return c.sort()
    };
    b.extend = function (a) {
        j(i.call(arguments, 1), function (b) {
            for (var d in b) a[d] = b[d]
        });
        return a
    };
    b.pick = function (a) {
        var c = {};
        j(b.flatten(i.call(arguments, 1)), function (b) {
            b in a && (c[b] = a[b])
        });
        return c
    };
    b.defaults = function (a) {
        j(i.call(arguments, 1), function (b) {
            for (var d in b) a[d] == null && (a[d] = b[d])
        });
        return a
    };
    b.clone = function (a) {
        return !b.isObject(a) ? a : b.isArray(a) ? a.slice() : b.extend({}, a)
    };
    b.tap = function (a, b) {
        b(a);
        return a
    };
    b.isEqual = function (a, b) {
        return r(a, b, [])
    };
    b.isEmpty = function (a) {
        if (a == null) return true;
        if (b.isArray(a) || b.isString(a)) return a.length === 0;
        for (var c in a)
            if (b.has(a, c)) return false;
        return true
    };
    b.isElement = function (a) {
        return !!(a && a.nodeType == 1)
    };
    b.isArray = p || function (a) {
        return l.call(a) == "[object Array]"
    };
    b.isObject = function (a) {
        return a === Object(a)
    };
    b.isArguments = function (a) {
        return l.call(a) == "[object Arguments]"
    };
    b.isArguments(arguments) || (b.isArguments = function (a) {
        return !(!a || !b.has(a, "callee"))
    });
    b.isFunction = function (a) {
        return l.call(a) == "[object Function]"
    };
    b.isString = function (a) {
        return l.call(a) == "[object String]"
    };
    b.isNumber = function (a) {
        return l.call(a) == "[object Number]"
    };
    b.isFinite = function (a) {
        return b.isNumber(a) && isFinite(a)
    };
    b.isNaN = function (a) {
        return a !== a
    };
    b.isBoolean = function (a) {
        return a === true || a === false || l.call(a) == "[object Boolean]"
    };
    b.isDate = function (a) {
        return l.call(a) == "[object Date]"
    };
    b.isRegExp = function (a) {
        return l.call(a) == "[object RegExp]"
    };
    b.isNull = function (a) {
        return a === null
    };
    b.isUndefined = function (a) {
        return a === void 0
    };
    b.has = function (a, b) {
        return K.call(a, b)
    };
    b.noConflict = function () {
        s._ = I;
        return this
    };
    b.identity = function (a) {
        return a
    };
    b.times = function (a, b, d) {
        for (var e = 0; e < a; e++) b.call(d, e)
    };
    b.escape = function (a) {
        return ("" + a).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;").replace(/\//g, "&#x2F;")
    };
    b.result = function (a, c) {
        if (a == null) return null;
        var d = a[c];
        return b.isFunction(d) ? d.call(a) : d
    };
    b.mixin = function (a) {
        j(b.functions(a), function (c) {
            M(c, b[c] = a[c])
        })
    };
    var N = 0;
    b.uniqueId = function (a) {
        var b = N++;
        return a ? a + b : b
    };
    b.templateSettings = {
        evaluate: /<%([\s\S]+?)%>/g,
        interpolate: /<%=([\s\S]+?)%>/g,
        escape: /<%-([\s\S]+?)%>/g
    };
    var u = /.^/,
        n = {
            "\\": "\\",
            "'": "'",
            r: "\r",
            n: "\n",
            t: "\t",
            u2028: "\u2028",
            u2029: "\u2029"
        }, v;
    for (v in n) n[n[v]] = v;
    var O = /\\|'|\r|\n|\t|\u2028|\u2029/g,
        P = /\\(\\|'|r|n|t|u2028|u2029)/g,
        w = function (a) {
            return a.replace(P, function (a, b) {
                return n[b]
            })
        };
    b.template = function (a, c, d) {
        d = b.defaults(d || {}, b.templateSettings);
        a = "__p+='" + a.replace(O, function (a) {
            return "\\" + n[a]
        }).replace(d.escape || u, function (a, b) {
            return "'+\n_.escape(" + w(b) + ")+\n'"
        }).replace(d.interpolate || u, function (a, b) {
            return "'+\n(" + w(b) + ")+\n'"
        }).replace(d.evaluate || u, function (a, b) {
            return "';\n" + w(b) + "\n;__p+='"
        }) + "';\n";
        d.variable || (a = "with(obj||{}){\n" + a + "}\n");
        var a = "var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n" + a + "return __p;\n",
            e = new Function(d.variable || "obj", "_", a);
        if (c) return e(c, b);
        c = function (a) {
            return e.call(this, a, b)
        };
        c.source = "function(" + (d.variable || "obj") + "){\n" + a + "}";
        return c
    };
    b.chain = function (a) {
        return b(a).chain()
    };
    var m = function (a) {
        this._wrapped = a
    };
    b.prototype = m.prototype;
    var x = function (a, c) {
        return c ? b(a).chain() : a
    }, M = function (a, c) {
            m.prototype[a] = function () {
                var a = i.call(arguments);
                J.call(a, this._wrapped);
                return x(c.apply(b, a), this._chain)
            }
        };
    b.mixin(b);
    j("pop,push,reverse,shift,sort,splice,unshift".split(","), function (a) {
        var b = k[a];
        m.prototype[a] = function () {
            var d = this._wrapped;
            b.apply(d, arguments);
            var e = d.length;
            (a == "shift" || a == "splice") && e === 0 && delete d[0];
            return x(d, this._chain)
        }
    });
    j(["concat", "join", "slice"], function (a) {
        var b = k[a];
        m.prototype[a] = function () {
            return x(b.apply(this._wrapped, arguments), this._chain)
        }
    });
    m.prototype.chain = function () {
        this._chain = true;
        return this
    };
    m.prototype.value = function () {
        return this._wrapped
    }
}).call(this); // Backbone.js 0.9.2

// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function () {
    var l = this,
        y = l.Backbone,
        z = Array.prototype.slice,
        A = Array.prototype.splice,
        g;
    g = "undefined" !== typeof exports ? exports : l.Backbone = {};
    g.VERSION = "0.9.2";
    var f = l._;
    !f && "undefined" !== typeof require && (f = require("underscore"));
    var i = l.jQuery || l.Zepto || l.ender;
    g.setDomLibrary = function (a) {
        i = a
    };
    g.noConflict = function () {
        l.Backbone = y;
        return this
    };
    g.emulateHTTP = !1;
    g.emulateJSON = !1;
    var p = /\s+/,
        k = g.Events = {
            on: function (a, b, c) {
                var d, e, f, g, j;
                if (!b) return this;
                a = a.split(p);
                for (d = this._callbacks || (this._callbacks = {}); e = a.shift();) f = (j = d[e]) ? j.tail : {}, f.next = g = {}, f.context = c, f.callback = b, d[e] = {
                    tail: g,
                    next: j ? j.next : f
                };
                return this
            },
            off: function (a, b, c) {
                var d, e, h, g, j, q;
                if (e = this._callbacks) {
                    if (!a && !b && !c) return delete this._callbacks, this;
                    for (a = a ? a.split(p) : f.keys(e); d = a.shift();)
                        if (h = e[d], delete e[d], h && (b || c))
                            for (g = h.tail;
                                (h = h.next) !== g;)
                                if (j = h.callback, q = h.context, b && j !== b || c && q !== c) this.on(d, j, q);
                    return this
                }
            },
            trigger: function (a) {
                var b, c, d, e, f, g;
                if (!(d = this._callbacks)) return this;
                f = d.all;
                a = a.split(p);
                for (g =
                    z.call(arguments, 1); b = a.shift();) {
                    if (c = d[b])
                        for (e = c.tail;
                            (c = c.next) !== e;) c.callback.apply(c.context || this, g);
                    if (c = f) {
                        e = c.tail;
                        for (b = [b].concat(g);
                            (c = c.next) !== e;) c.callback.apply(c.context || this, b)
                    }
                }
                return this
            }
        };
    k.bind = k.on;
    k.unbind = k.off;
    var o = g.Model = function (a, b) {
        var c;
        a || (a = {});
        b && b.parse && (a = this.parse(a));
        if (c = n(this, "defaults")) a = f.extend({}, c, a);
        b && b.collection && (this.collection = b.collection);
        this.attributes = {};
        this._escapedAttributes = {};
        this.cid = f.uniqueId("c");
        this.changed = {};
        this._silent = {};
        this._pending = {};
        this.set(a, {
            silent: !0
        });
        this.changed = {};
        this._silent = {};
        this._pending = {};
        this._previousAttributes = f.clone(this.attributes);
        this.initialize.apply(this, arguments)
    };
    f.extend(o.prototype, k, {
        changed: null,
        _silent: null,
        _pending: null,
        idAttribute: "id",
        initialize: function () {},
        toJSON: function () {
            return f.clone(this.attributes)
        },
        get: function (a) {
            return this.attributes[a]
        },
        escape: function (a) {
            var b;
            if (b = this._escapedAttributes[a]) return b;
            b = this.get(a);
            return this._escapedAttributes[a] = f.escape(null ==
                b ? "" : "" + b)
        },
        has: function (a) {
            return null != this.get(a)
        },
        set: function (a, b, c) {
            var d, e;
            f.isObject(a) || null == a ? (d = a, c = b) : (d = {}, d[a] = b);
            c || (c = {});
            if (!d) return this;
            d instanceof o && (d = d.attributes);
            if (c.unset)
                for (e in d) d[e] = void 0;
            if (!this._validate(d, c)) return !1;
            this.idAttribute in d && (this.id = d[this.idAttribute]);
            var b = c.changes = {}, h = this.attributes,
                g = this._escapedAttributes,
                j = this._previousAttributes || {};
            for (e in d) {
                a = d[e];
                if (!f.isEqual(h[e], a) || c.unset && f.has(h, e)) delete g[e], (c.silent ? this._silent :
                    b)[e] = !0;
                c.unset ? delete h[e] : h[e] = a;
                !f.isEqual(j[e], a) || f.has(h, e) != f.has(j, e) ? (this.changed[e] = a, c.silent || (this._pending[e] = !0)) : (delete this.changed[e], delete this._pending[e])
            }
            c.silent || this.change(c);
            return this
        },
        unset: function (a, b) {
            (b || (b = {})).unset = !0;
            return this.set(a, null, b)
        },
        clear: function (a) {
            (a || (a = {})).unset = !0;
            return this.set(f.clone(this.attributes), a)
        },
        fetch: function (a) {
            var a = a ? f.clone(a) : {}, b = this,
                c = a.success;
            a.success = function (d, e, f) {
                if (!b.set(b.parse(d, f), a)) return !1;
                c && c(b, d)
            };
            a.error = g.wrapError(a.error, b, a);
            return (this.sync || g.sync).call(this, "read", this, a)
        },
        save: function (a, b, c) {
            var d, e;
            f.isObject(a) || null == a ? (d = a, c = b) : (d = {}, d[a] = b);
            c = c ? f.clone(c) : {};
            if (c.wait) {
                if (!this._validate(d, c)) return !1;
                e = f.clone(this.attributes)
            }
            a = f.extend({}, c, {
                silent: !0
            });
            if (d && !this.set(d, c.wait ? a : c)) return !1;
            var h = this,
                i = c.success;
            c.success = function (a, b, e) {
                b = h.parse(a, e);
                if (c.wait) {
                    delete c.wait;
                    b = f.extend(d || {}, b)
                }
                if (!h.set(b, c)) return false;
                i ? i(h, a) : h.trigger("sync", h, a, c)
            };
            c.error = g.wrapError(c.error,
                h, c);
            b = this.isNew() ? "create" : "update";
            b = (this.sync || g.sync).call(this, b, this, c);
            c.wait && this.set(e, a);
            return b
        },
        destroy: function (a) {
            var a = a ? f.clone(a) : {}, b = this,
                c = a.success,
                d = function () {
                    b.trigger("destroy", b, b.collection, a)
                };
            if (this.isNew()) return d(), !1;
            a.success = function (e) {
                a.wait && d();
                c ? c(b, e) : b.trigger("sync", b, e, a)
            };
            a.error = g.wrapError(a.error, b, a);
            var e = (this.sync || g.sync).call(this, "delete", this, a);
            a.wait || d();
            return e
        },
        url: function () {
            var a = n(this, "urlRoot") || n(this.collection, "url") || t();
            return this.isNew() ? a : a + ("/" == a.charAt(a.length - 1) ? "" : "/") + encodeURIComponent(this.id)
        },
        parse: function (a) {
            return a
        },
        clone: function () {
            return new this.constructor(this.attributes)
        },
        isNew: function () {
            return null == this.id
        },
        change: function (a) {
            a || (a = {});
            var b = this._changing;
            this._changing = !0;
            for (var c in this._silent) this._pending[c] = !0;
            var d = f.extend({}, a.changes, this._silent);
            this._silent = {};
            for (c in d) this.trigger("change:" + c, this, this.get(c), a);
            if (b) return this;
            for (; !f.isEmpty(this._pending);) {
                this._pending = {};
                this.trigger("change", this, a);
                for (c in this.changed)!this._pending[c] && !this._silent[c] && delete this.changed[c];
                this._previousAttributes = f.clone(this.attributes)
            }
            this._changing = !1;
            return this
        },
        hasChanged: function (a) {
            return !arguments.length ? !f.isEmpty(this.changed) : f.has(this.changed, a)
        },
        changedAttributes: function (a) {
            if (!a) return this.hasChanged() ? f.clone(this.changed) : !1;
            var b, c = !1,
                d = this._previousAttributes,
                e;
            for (e in a)
                if (!f.isEqual(d[e], b = a[e]))(c || (c = {}))[e] = b;
            return c
        },
        previous: function (a) {
            return !arguments.length || !this._previousAttributes ? null : this._previousAttributes[a]
        },
        previousAttributes: function () {
            return f.clone(this._previousAttributes)
        },
        isValid: function () {
            return !this.validate(this.attributes)
        },
        _validate: function (a, b) {
            if (b.silent || !this.validate) return !0;
            var a = f.extend({}, this.attributes, a),
                c = this.validate(a, b);
            if (!c) return !0;
            b && b.error ? b.error(this, c, b) : this.trigger("error", this, c, b);
            return !1
        }
    });
    var r = g.Collection = function (a, b) {
        b || (b = {});
        b.model && (this.model = b.model);
        b.comparator && (this.comparator = b.comparator);
        this._reset();
        this.initialize.apply(this, arguments);
        a && this.reset(a, {
            silent: !0,
            parse: b.parse
        })
    };
    f.extend(r.prototype, k, {
        model: o,
        initialize: function () {},
        toJSON: function (a) {
            return this.map(function (b) {
                return b.toJSON(a)
            })
        },
        add: function (a, b) {
            var c, d, e, g, i, j = {}, k = {}, l = [];
            b || (b = {});
            a = f.isArray(a) ? a.slice() : [a];
            c = 0;
            for (d = a.length; c < d; c++) {
                if (!(e = a[c] = this._prepareModel(a[c], b))) throw Error("Can't add an invalid model to a collection");
                g = e.cid;
                i = e.id;
                j[g] || this._byCid[g] || null != i && (k[i] || this._byId[i]) ?
                    l.push(c) : j[g] = k[i] = e
            }
            for (c = l.length; c--;) a.splice(l[c], 1);
            c = 0;
            for (d = a.length; c < d; c++)(e = a[c]).on("all", this._onModelEvent, this), this._byCid[e.cid] = e, null != e.id && (this._byId[e.id] = e);
            this.length += d;
            A.apply(this.models, [null != b.at ? b.at : this.models.length, 0].concat(a));
            this.comparator && this.sort({
                silent: !0
            });
            if (b.silent) return this;
            c = 0;
            for (d = this.models.length; c < d; c++)
                if (j[(e = this.models[c]).cid]) b.index = c, e.trigger("add", e, this, b);
            return this
        },
        remove: function (a, b) {
            var c, d, e, g;
            b || (b = {});
            a = f.isArray(a) ?
                a.slice() : [a];
            c = 0;
            for (d = a.length; c < d; c++)
                if (g = this.getByCid(a[c]) || this.get(a[c])) delete this._byId[g.id], delete this._byCid[g.cid], e = this.indexOf(g), this.models.splice(e, 1), this.length--, b.silent || (b.index = e, g.trigger("remove", g, this, b)), this._removeReference(g);
            return this
        },
        push: function (a, b) {
            a = this._prepareModel(a, b);
            this.add(a, b);
            return a
        },
        pop: function (a) {
            var b = this.at(this.length - 1);
            this.remove(b, a);
            return b
        },
        unshift: function (a, b) {
            a = this._prepareModel(a, b);
            this.add(a, f.extend({
                at: 0
            }, b));
            return a
        },
        shift: function (a) {
            var b = this.at(0);
            this.remove(b, a);
            return b
        },
        get: function (a) {
            return null == a ? void 0 : this._byId[null != a.id ? a.id : a]
        },
        getByCid: function (a) {
            return a && this._byCid[a.cid || a]
        },
        at: function (a) {
            return this.models[a]
        },
        where: function (a) {
            return f.isEmpty(a) ? [] : this.filter(function (b) {
                for (var c in a)
                    if (a[c] !== b.get(c)) return !1;
                return !0
            })
        },
        sort: function (a) {
            a || (a = {});
            if (!this.comparator) throw Error("Cannot sort a set without a comparator");
            var b = f.bind(this.comparator, this);
            1 == this.comparator.length ?
                this.models = this.sortBy(b) : this.models.sort(b);
            a.silent || this.trigger("reset", this, a);
            return this
        },
        pluck: function (a) {
            return f.map(this.models, function (b) {
                return b.get(a)
            })
        },
        reset: function (a, b) {
            a || (a = []);
            b || (b = {});
            for (var c = 0, d = this.models.length; c < d; c++) this._removeReference(this.models[c]);
            this._reset();
            this.add(a, f.extend({
                silent: !0
            }, b));
            b.silent || this.trigger("reset", this, b);
            return this
        },
        fetch: function (a) {
            a = a ? f.clone(a) : {};
            void 0 === a.parse && (a.parse = !0);
            var b = this,
                c = a.success;
            a.success = function (d,
                e, f) {
                b[a.add ? "add" : "reset"](b.parse(d, f), a);
                c && c(b, d)
            };
            a.error = g.wrapError(a.error, b, a);
            return (this.sync || g.sync).call(this, "read", this, a)
        },
        create: function (a, b) {
            var c = this,
                b = b ? f.clone(b) : {}, a = this._prepareModel(a, b);
            if (!a) return !1;
            b.wait || c.add(a, b);
            var d = b.success;
            b.success = function (e, f) {
                b.wait && c.add(e, b);
                d ? d(e, f) : e.trigger("sync", a, f, b)
            };
            a.save(null, b);
            return a
        },
        parse: function (a) {
            return a
        },
        chain: function () {
            return f(this.models).chain()
        },
        _reset: function () {
            this.length = 0;
            this.models = [];
            this._byId = {};
            this._byCid = {}
        },
        _prepareModel: function (a, b) {
            b || (b = {});
            a instanceof o ? a.collection || (a.collection = this) : (b.collection = this, a = new this.model(a, b), a._validate(a.attributes, b) || (a = !1));
            return a
        },
        _removeReference: function (a) {
            this == a.collection && delete a.collection;
            a.off("all", this._onModelEvent, this)
        },
        _onModelEvent: function (a, b, c, d) {
            ("add" == a || "remove" == a) && c != this || ("destroy" == a && this.remove(b, d), b && a === "change:" + b.idAttribute && (delete this._byId[b.previous(b.idAttribute)], this._byId[b.id] = b), this.trigger.apply(this,
                arguments))
        }
    });
    f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","), function (a) {
        r.prototype[a] = function () {
            return f[a].apply(f, [this.models].concat(f.toArray(arguments)))
        }
    });
    var u = g.Router = function (a) {
        a || (a = {});
        a.routes && (this.routes = a.routes);
        this._bindRoutes();
        this.initialize.apply(this, arguments)
    }, B = /:\w+/g,
        C = /\*\w+/g,
        D = /[-[\]{}()+?.,\\^$|#\s]/g;
    f.extend(u.prototype, k, {
        initialize: function () {},
        route: function (a, b, c) {
            g.history || (g.history = new m);
            f.isRegExp(a) || (a = this._routeToRegExp(a));
            c || (c = this[b]);
            g.history.route(a, f.bind(function (d) {
                d = this._extractParameters(a, d);
                c && c.apply(this, d);
                this.trigger.apply(this, ["route:" + b].concat(d));
                g.history.trigger("route", this, b, d)
            }, this));
            return this
        },
        navigate: function (a, b) {
            g.history.navigate(a, b)
        },
        _bindRoutes: function () {
            if (this.routes) {
                var a = [],
                    b;
                for (b in this.routes) a.unshift([b,
                    this.routes[b]
                ]);
                b = 0;
                for (var c = a.length; b < c; b++) this.route(a[b][0], a[b][1], this[a[b][1]])
            }
        },
        _routeToRegExp: function (a) {
            a = a.replace(D, "\\$&").replace(B, "([^/]+)").replace(C, "(.*?)");
            return RegExp("^" + a + "$")
        },
        _extractParameters: function (a, b) {
            return a.exec(b).slice(1)
        }
    });
    var m = g.History = function () {
        this.handlers = [];
        f.bindAll(this, "checkUrl")
    }, s = /^[#\/]/,
        E = /msie [\w.]+/;
    m.started = !1;
    f.extend(m.prototype, k, {
        interval: 50,
        getHash: function (a) {
            return (a = (a ? a.location : window.location).href.match(/#(.*)$/)) ? a[1] :
                ""
        },
        getFragment: function (a, b) {
            if (null == a)
                if (this._hasPushState || b) {
                    var a = window.location.pathname,
                        c = window.location.search;
                    c && (a += c)
                } else a = this.getHash();
            a.indexOf(this.options.root) || (a = a.substr(this.options.root.length));
            return a.replace(s, "")
        },
        start: function (a) {
            if (m.started) throw Error("Backbone.history has already been started");
            m.started = !0;
            this.options = f.extend({}, {
                root: "/"
            }, this.options, a);
            this._wantsHashChange = !1 !== this.options.hashChange;
            this._wantsPushState = !! this.options.pushState;
            this._hasPushState = !(!this.options.pushState || !window.history || !window.history.pushState);
            var a = this.getFragment(),
                b = document.documentMode;
            if (b = E.exec(navigator.userAgent.toLowerCase()) && (!b || 7 >= b)) this.iframe = i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow, this.navigate(a);
            this._hasPushState ? i(window).bind("popstate", this.checkUrl) : this._wantsHashChange && "onhashchange" in window && !b ? i(window).bind("hashchange", this.checkUrl) : this._wantsHashChange && (this._checkUrlInterval = setInterval(this.checkUrl,
                this.interval));
            this.fragment = a;
            a = window.location;
            b = a.pathname == this.options.root;
            if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !b) return this.fragment = this.getFragment(null, !0), window.location.replace(this.options.root + "#" + this.fragment), !0;
            this._wantsPushState && this._hasPushState && b && a.hash && (this.fragment = this.getHash().replace(s, ""), window.history.replaceState({}, document.title, a.protocol + "//" + a.host + this.options.root + this.fragment));
            if (!this.options.silent) return this.loadUrl()
        },
        stop: function () {
            i(window).unbind("popstate", this.checkUrl).unbind("hashchange", this.checkUrl);
            clearInterval(this._checkUrlInterval);
            m.started = !1
        },
        route: function (a, b) {
            this.handlers.unshift({
                route: a,
                callback: b
            })
        },
        checkUrl: function () {
            var a = this.getFragment();
            a == this.fragment && this.iframe && (a = this.getFragment(this.getHash(this.iframe)));
            if (a == this.fragment) return !1;
            this.iframe && this.navigate(a);
            this.loadUrl() || this.loadUrl(this.getHash())
        },
        loadUrl: function (a) {
            var b = this.fragment = this.getFragment(a);
            return f.any(this.handlers,
                function (a) {
                    if (a.route.test(b)) return a.callback(b), !0
                })
        },
        navigate: function (a, b) {
            if (!m.started) return !1;
            if (!b || !0 === b) b = {
                trigger: b
            };
            var c = (a || "").replace(s, "");
            this.fragment != c && (this._hasPushState ? (0 != c.indexOf(this.options.root) && (c = this.options.root + c), this.fragment = c, window.history[b.replace ? "replaceState" : "pushState"]({}, document.title, c)) : this._wantsHashChange ? (this.fragment = c, this._updateHash(window.location, c, b.replace), this.iframe && c != this.getFragment(this.getHash(this.iframe)) && (b.replace ||
                this.iframe.document.open().close(), this._updateHash(this.iframe.location, c, b.replace))) : window.location.assign(this.options.root + a), b.trigger && this.loadUrl(a))
        },
        _updateHash: function (a, b, c) {
            c ? a.replace(a.toString().replace(/(javascript:|#).*$/, "") + "#" + b) : a.hash = b
        }
    });
    var v = g.View = function (a) {
        this.cid = f.uniqueId("view");
        this._configure(a || {});
        this._ensureElement();
        this.initialize.apply(this, arguments);
        this.delegateEvents()
    }, F = /^(\S+)\s*(.*)$/,
        w = "model,collection,el,id,attributes,className,tagName".split(",");
    f.extend(v.prototype, k, {
        tagName: "div",
        $: function (a) {
            return this.$el.find(a)
        },
        initialize: function () {},
        render: function () {
            return this
        },
        remove: function () {
            this.$el.remove();
            return this
        },
        make: function (a, b, c) {
            a = document.createElement(a);
            b && i(a).attr(b);
            c && i(a).html(c);
            return a
        },
        setElement: function (a, b) {
            this.$el && this.undelegateEvents();
            this.$el = a instanceof i ? a : i(a);
            this.el = this.$el[0];
            !1 !== b && this.delegateEvents();
            return this
        },
        delegateEvents: function (a) {
            if (a || (a = n(this, "events"))) {
                this.undelegateEvents();
                for (var b in a) {
                    var c = a[b];
                    f.isFunction(c) || (c = this[a[b]]);
                    if (!c) throw Error('Method "' + a[b] + '" does not exist');
                    var d = b.match(F),
                        e = d[1],
                        d = d[2],
                        c = f.bind(c, this),
                        e = e + (".delegateEvents" + this.cid);
                    "" === d ? this.$el.bind(e, c) : this.$el.delegate(d, e, c)
                }
            }
        },
        undelegateEvents: function () {
            this.$el.unbind(".delegateEvents" + this.cid)
        },
        _configure: function (a) {
            this.options && (a = f.extend({}, this.options, a));
            for (var b = 0, c = w.length; b < c; b++) {
                var d = w[b];
                a[d] && (this[d] = a[d])
            }
            this.options = a
        },
        _ensureElement: function () {
            if (this.el) this.setElement(this.el, !1);
            else {
                var a = n(this, "attributes") || {};
                this.id && (a.id = this.id);
                this.className && (a["class"] = this.className);
                this.setElement(this.make(this.tagName, a), !1)
            }
        }
    });
    o.extend = r.extend = u.extend = v.extend = function (a, b) {
        var c = G(this, a, b);
        c.extend = this.extend;
        return c
    };
    var H = {
        create: "POST",
        update: "PUT",
        "delete": "DELETE",
        read: "GET"
    };
    g.sync = function (a, b, c) {
        var d = H[a];
        c || (c = {});
        var e = {
            type: d,
            dataType: "json"
        };
        c.url || (e.url = n(b, "url") || t());
        if (!c.data && b && ("create" == a || "update" == a)) e.contentType = "application/json",
        e.data = JSON.stringify(b.toJSON());
        g.emulateJSON && (e.contentType = "application/x-www-form-urlencoded", e.data = e.data ? {
            model: e.data
        } : {});
        if (g.emulateHTTP && ("PUT" === d || "DELETE" === d)) g.emulateJSON && (e.data._method = d), e.type = "POST", e.beforeSend = function (a) {
            a.setRequestHeader("X-HTTP-Method-Override", d)
        };
        "GET" !== e.type && !g.emulateJSON && (e.processData = !1);
        return i.ajax(f.extend(e, c))
    };
    g.wrapError = function (a, b, c) {
        return function (d, e) {
            e = d === b ? e : d;
            a ? a(b, e, c) : b.trigger("error", b, e, c)
        }
    };
    var x = function () {}, G = function (a,
            b, c) {
            var d;
            d = b && b.hasOwnProperty("constructor") ? b.constructor : function () {
                a.apply(this, arguments)
            };
            f.extend(d, a);
            x.prototype = a.prototype;
            d.prototype = new x;
            b && f.extend(d.prototype, b);
            c && f.extend(d, c);
            d.prototype.constructor = d;
            d.__super__ = a.prototype;
            return d
        }, n = function (a, b) {
            return !a || !a[b] ? null : f.isFunction(a[b]) ? a[b]() : a[b]
        }, t = function () {
            throw Error('A "url" property or function must be specified');
        }
}).call(this);
// moment.js
// version : 1.7.2
// author : Tim Wood
// license : MIT
// momentjs.com
(function (a) {
    function E(a, b, c, d) {
        var e = c.lang();
        return e[a].call ? e[a](c, d) : e[a][b]
    }

    function F(a, b) {
        return function (c) {
            return K(a.call(this, c), b)
        }
    }

    function G(a) {
        return function (b) {
            var c = a.call(this, b);
            return c + this.lang().ordinal(c)
        }
    }

    function H(a, b, c) {
        this._d = a, this._isUTC = !! b, this._a = a._a || null, this._lang = c || !1
    }

    function I(a) {
        var b = this._data = {}, c = a.years || a.y || 0,
            d = a.months || a.M || 0,
            e = a.weeks || a.w || 0,
            f = a.days || a.d || 0,
            g = a.hours || a.h || 0,
            h = a.minutes || a.m || 0,
            i = a.seconds || a.s || 0,
            j = a.milliseconds || a.ms || 0;
        this._milliseconds = j + i * 1e3 + h * 6e4 + g * 36e5, this._days = f + e * 7, this._months = d + c * 12, b.milliseconds = j % 1e3, i += J(j / 1e3), b.seconds = i % 60, h += J(i / 60), b.minutes = h % 60, g += J(h / 60), b.hours = g % 24, f += J(g / 24), f += e * 7, b.days = f % 30, d += J(f / 30), b.months = d % 12, c += J(d / 12), b.years = c, this._lang = !1
    }

    function J(a) {
        return a < 0 ? Math.ceil(a) : Math.floor(a)
    }

    function K(a, b) {
        var c = a + "";
        while (c.length < b) c = "0" + c;
        return c
    }

    function L(a, b, c) {
        var d = b._milliseconds,
            e = b._days,
            f = b._months,
            g;
        d && a._d.setTime(+a + d * c), e && a.date(a.date() + e * c), f && (g = a.date(), a.date(1).month(a.month() + f * c).date(Math.min(g, a.daysInMonth())))
    }

    function M(a) {
        return Object.prototype.toString.call(a) === "[object Array]"
    }

    function N(a, b) {
        var c = Math.min(a.length, b.length),
            d = Math.abs(a.length - b.length),
            e = 0,
            f;
        for (f = 0; f < c; f++)~~ a[f] !== ~~b[f] && e++;
        return e + d
    }

    function O(a, b, c, d) {
        var e, f, g = [];
        for (e = 0; e < 7; e++) g[e] = a[e] = a[e] == null ? e === 2 ? 1 : 0 : a[e];
        return a[7] = g[7] = b, a[8] != null && (g[8] = a[8]), a[3] += c || 0, a[4] += d || 0, f = new Date(0), b ? (f.setUTCFullYear(a[0], a[1], a[2]), f.setUTCHours(a[3], a[4], a[5], a[6])) : (f.setFullYear(a[0], a[1], a[2]), f.setHours(a[3], a[4], a[5], a[6])), f._a = g, f
    }

    function P(a, c) {
        var d, e, g = [];
        !c && h && (c = require("./lang/" + a));
        for (d = 0; d < i.length; d++) c[i[d]] = c[i[d]] || f.en[i[d]];
        for (d = 0; d < 12; d++) e = b([2e3, d]), g[d] = new RegExp("^" + (c.months[d] || c.months(e, "")) + "|^" + (c.monthsShort[d] || c.monthsShort(e, "")).replace(".", ""), "i");
        return c.monthsParse = c.monthsParse || g, f[a] = c, c
    }

    function Q(a) {
        var c = typeof a == "string" && a || a && a._lang || null;
        return c ? f[c] || P(c) : b
    }

    function R(a) {
        return a.match(/\[.*\]/) ? a.replace(/^\[|\]$/g, "") : a.replace(/\\/g, "")
    }

    function S(a) {
        var b = a.match(k),
            c, d;
        for (c = 0, d = b.length; c < d; c++) D[b[c]] ? b[c] = D[b[c]] : b[c] = R(b[c]);
        return function (e) {
            var f = "";
            for (c = 0; c < d; c++) f += typeof b[c].call == "function" ? b[c].call(e, a) : b[c];
            return f
        }
    }

    function T(a, b) {
        function d(b) {
            return a.lang().longDateFormat[b] || b
        }
        var c = 5;
        while (c-- && l.test(b)) b = b.replace(l, d);
        return A[b] || (A[b] = S(b)), A[b](a)
    }

    function U(a) {
        switch (a) {
        case "DDDD":
            return p;
        case "YYYY":
            return q;
        case "S":
        case "SS":
        case "SSS":
        case "DDD":
            return o;
        case "MMM":
        case "MMMM":
        case "dd":
        case "ddd":
        case "dddd":
        case "a":
        case "A":
            return r;
        case "Z":
        case "ZZ":
            return s;
        case "T":
            return t;
        case "MM":
        case "DD":
        case "YY":
        case "HH":
        case "hh":
        case "mm":
        case "ss":
        case "M":
        case "D":
        case "d":
        case "H":
        case "h":
        case "m":
        case "s":
            return n;
        default:
            return new RegExp(a.replace("\\", ""))
        }
    }

    function V(a, b, c, d) {
        var e, f;
        switch (a) {
        case "M":
        case "MM":
            c[1] = b == null ? 0 : ~~b - 1;
            break;
        case "MMM":
        case "MMMM":
            for (e = 0; e < 12; e++)
                if (Q().monthsParse[e].test(b)) {
                    c[1] = e, f = !0;
                    break
                }
            f || (c[8] = !1);
            break;
        case "D":
        case "DD":
        case "DDD":
        case "DDDD":
            b != null && (c[2] = ~~b);
            break;
        case "YY":
            c[0] = ~~b + (~~b > 70 ? 1900 : 2e3);
            break;
        case "YYYY":
            c[0] = ~~Math.abs(b);
            break;
        case "a":
        case "A":
            d.isPm = (b + "").toLowerCase() === "pm";
            break;
        case "H":
        case "HH":
        case "h":
        case "hh":
            c[3] = ~~b;
            break;
        case "m":
        case "mm":
            c[4] = ~~b;
            break;
        case "s":
        case "ss":
            c[5] = ~~b;
            break;
        case "S":
        case "SS":
        case "SSS":
            c[6] = ~~ (("0." + b) * 1e3);
            break;
        case "Z":
        case "ZZ":
            d.isUTC = !0, e = (b + "").match(x), e && e[1] && (d.tzh = ~~e[1]), e && e[2] && (d.tzm = ~~e[2]), e && e[0] === "+" && (d.tzh = -d.tzh, d.tzm = -d.tzm)
        }
        b == null && (c[8] = !1)
    }

    function W(a, b) {
        var c = [0, 0, 1, 0, 0, 0, 0],
            d = {
                tzh: 0,
                tzm: 0
            }, e = b.match(k),
            f, g;
        for (f = 0; f < e.length; f++) g = (U(e[f]).exec(a) || [])[0], g && (a = a.slice(a.indexOf(g) + g.length)), D[e[f]] && V(e[f], g, c, d);
        return d.isPm && c[3] < 12 && (c[3] += 12), d.isPm === !1 && c[3] === 12 && (c[3] = 0), O(c, d.isUTC, d.tzh, d.tzm)
    }

    function X(a, b) {
        var c, d = a.match(m) || [],
            e, f = 99,
            g, h, i;
        for (g = 0; g < b.length; g++) h = W(a, b[g]), e = T(new H(h), b[g]).match(m) || [], i = N(d, e), i < f && (f = i, c = h);
        return c
    }

    function Y(a) {
        var b = "YYYY-MM-DDT",
            c;
        if (u.exec(a)) {
            for (c = 0; c < 4; c++)
                if (w[c][1].exec(a)) {
                    b += w[c][0];
                    break
                }
            return s.exec(a) ? W(a, b + " Z") : W(a, b)
        }
        return new Date(a)
    }

    function Z(a, b, c, d, e) {
        var f = e.relativeTime[a];
        return typeof f == "function" ? f(b || 1, !! c, a, d) : f.replace(/%d/i, b || 1)
    }

    function $(a, b, c) {
        var e = d(Math.abs(a) / 1e3),
            f = d(e / 60),
            g = d(f / 60),
            h = d(g / 24),
            i = d(h / 365),
            j = e < 45 && ["s", e] || f === 1 && ["m"] || f < 45 && ["mm", f] || g === 1 && ["h"] || g < 22 && ["hh", g] || h === 1 && ["d"] || h <= 25 && ["dd", h] || h <= 45 && ["M"] || h < 345 && ["MM", d(h / 30)] || i === 1 && ["y"] || ["yy", i];
        return j[2] = b, j[3] = a > 0, j[4] = c, Z.apply({}, j)
    }

    function _(a, c) {
        b.fn[a] = function (a) {
            var b = this._isUTC ? "UTC" : "";
            return a != null ? (this._d["set" + b + c](a), this) : this._d["get" + b + c]()
        }
    }

    function ab(a) {
        b.duration.fn[a] = function () {
            return this._data[a]
        }
    }

    function bb(a, c) {
        b.duration.fn["as" + a] = function () {
            return +this / c
        }
    }
    var b, c = "1.7.2",
        d = Math.round,
        e, f = {}, g = "en",
        h = typeof module != "undefined" && module.exports,
        i = "months|monthsShort|weekdays|weekdaysShort|weekdaysMin|longDateFormat|calendar|relativeTime|ordinal|meridiem".split("|"),
        j = /^\/?Date\((\-?\d+)/i,
        k = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|.)/g,
        l = /(\[[^\[]*\])|(\\)?(LT|LL?L?L?)/g,
        m = /([0-9a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)/gi,
        n = /\d\d?/,
        o = /\d{1,3}/,
        p = /\d{3}/,
        q = /\d{1,4}/,
        r = /[0-9a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+/i,
        s = /Z|[\+\-]\d\d:?\d\d/i,
        t = /T/i,
        u = /^\s*\d{4}-\d\d-\d\d(T(\d\d(:\d\d(:\d\d(\.\d\d?\d?)?)?)?)?([\+\-]\d\d:?\d\d)?)?/,
        v = "YYYY-MM-DDTHH:mm:ssZ",
        w = [
            ["HH:mm:ss.S", /T\d\d:\d\d:\d\d\.\d{1,3}/],
            ["HH:mm:ss", /T\d\d:\d\d:\d\d/],
            ["HH:mm", /T\d\d:\d\d/],
            ["HH", /T\d\d/]
        ],
        x = /([\+\-]|\d\d)/gi,
        y = "Month|Date|Hours|Minutes|Seconds|Milliseconds".split("|"),
        z = {
            Milliseconds: 1,
            Seconds: 1e3,
            Minutes: 6e4,
            Hours: 36e5,
            Days: 864e5,
            Months: 2592e6,
            Years: 31536e6
        }, A = {}, B = "DDD w M D d".split(" "),
        C = "M D H h m s w".split(" "),
        D = {
            M: function () {
                return this.month() + 1
            },
            MMM: function (a) {
                return E("monthsShort", this.month(), this, a)
            },
            MMMM: function (a) {
                return E("months", this.month(), this, a)
            },
            D: function () {
                return this.date()
            },
            DDD: function () {
                var a = new Date(this.year(), this.month(), this.date()),
                    b = new Date(this.year(), 0, 1);
                return~~ ((a - b) / 864e5 + 1.5)
            },
            d: function () {
                return this.day()
            },
            dd: function (a) {
                return E("weekdaysMin", this.day(), this, a)
            },
            ddd: function (a) {
                return E("weekdaysShort", this.day(), this, a)
            },
            dddd: function (a) {
                return E("weekdays", this.day(), this, a)
            },
            w: function () {
                var a = new Date(this.year(), this.month(), this.date() - this.day() + 5),
                    b = new Date(a.getFullYear(), 0, 4);
                return~~ ((a - b) / 864e5 / 7 + 1.5)
            },
            YY: function () {
                return K(this.year() % 100, 2)
            },
            YYYY: function () {
                return K(this.year(), 4)
            },
            a: function () {
                return this.lang().meridiem(this.hours(), this.minutes(), !0)
            },
            A: function () {
                return this.lang().meridiem(this.hours(), this.minutes(), !1)
            },
            H: function () {
                return this.hours()
            },
            h: function () {
                return this.hours() % 12 || 12
            },
            m: function () {
                return this.minutes()
            },
            s: function () {
                return this.seconds()
            },
            S: function () {
                return~~ (this.milliseconds() / 100)
            },
            SS: function () {
                return K(~~(this.milliseconds() / 10), 2)
            },
            SSS: function () {
                return K(this.milliseconds(), 3)
            },
            Z: function () {
                var a = -this.zone(),
                    b = "+";
                return a < 0 && (a = -a, b = "-"), b + K(~~(a / 60), 2) + ":" + K(~~a % 60, 2)
            },
            ZZ: function () {
                var a = -this.zone(),
                    b = "+";
                return a < 0 && (a = -a, b = "-"), b + K(~~(10 * a / 6), 4)
            }
        };
    while (B.length) e = B.pop(), D[e + "o"] = G(D[e]);
    while (C.length) e = C.pop(), D[e + e] = F(D[e], 2);
    D.DDDD = F(D.DDD, 3), b = function (c, d) {
        if (c === null || c === "") return null;
        var e, f;
        return b.isMoment(c) ? new H(new Date(+c._d), c._isUTC, c._lang) : (d ? M(d) ? e = X(c, d) : e = W(c, d) : (f = j.exec(c), e = c === a ? new Date : f ? new Date(+f[1]) : c instanceof Date ? c : M(c) ? O(c) : typeof c == "string" ? Y(c) : new Date(c)), new H(e))
    }, b.utc = function (a, c) {
        return M(a) ? new H(O(a, !0), !0) : (typeof a == "string" && !s.exec(a) && (a += " +0000", c && (c += " Z")), b(a, c).utc())
    }, b.unix = function (a) {
        return b(a * 1e3)
    }, b.duration = function (a, c) {
        var d = b.isDuration(a),
            e = typeof a == "number",
            f = d ? a._data : e ? {} : a,
            g;
        return e && (c ? f[c] = a : f.milliseconds = a), g = new I(f), d && (g._lang = a._lang), g
    }, b.humanizeDuration = function (a, c, d) {
        return b.duration(a, c === !0 ? null : c).humanize(c === !0 ? !0 : d)
    }, b.version = c, b.defaultFormat = v, b.lang = function (a, c) {
        var d;
        if (!a) return g;
        (c || !f[a]) && P(a, c);
        if (f[a]) {
            for (d = 0; d < i.length; d++) b[i[d]] = f[a][i[d]];
            b.monthsParse = f[a].monthsParse, g = a
        }
    }, b.langData = Q, b.isMoment = function (a) {
        return a instanceof H
    }, b.isDuration = function (a) {
        return a instanceof I
    }, b.lang("en", {
        months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
        monthsShort: "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),
        weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
        weekdaysShort: "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),
        weekdaysMin: "Su_Mo_Tu_We_Th_Fr_Sa".split("_"),
        longDateFormat: {
            LT: "h:mm A",
            L: "MM/DD/YYYY",
            LL: "MMMM D YYYY",
            LLL: "MMMM D YYYY LT",
            LLLL: "dddd, MMMM D YYYY LT"
        },
        meridiem: function (a, b, c) {
            return a > 11 ? c ? "pm" : "PM" : c ? "am" : "AM"
        },
        calendar: {
            sameDay: "[Today at] LT",
            nextDay: "[Tomorrow at] LT",
            nextWeek: "dddd [at] LT",
            lastDay: "[Yesterday at] LT",
            lastWeek: "[last] dddd [at] LT",
            sameElse: "L"
        },
        relativeTime: {
            future: "in %s",
            past: "%s ago",
            s: "a few seconds",
            m: "a minute",
            mm: "%d minutes",
            h: "an hour",
            hh: "%d hours",
            d: "a day",
            dd: "%d days",
            M: "a month",
            MM: "%d months",
            y: "a year",
            yy: "%d years"
        },
        ordinal: function (a) {
            var b = a % 10;
            return~~ (a % 100 / 10) === 1 ? "th" : b === 1 ? "st" : b === 2 ? "nd" : b === 3 ? "rd" : "th"
        }
    }), b.fn = H.prototype = {
        clone: function () {
            return b(this)
        },
        valueOf: function () {
            return +this._d
        },
        unix: function () {
            return Math.floor(+this._d / 1e3)
        },
        toString: function () {
            return this._d.toString()
        },
        toDate: function () {
            return this._d
        },
        toArray: function () {
            var a = this;
            return [a.year(), a.month(), a.date(), a.hours(), a.minutes(), a.seconds(), a.milliseconds(), !! this._isUTC]
        },
        isValid: function () {
            return this._a ? this._a[8] != null ? !! this._a[8] : !N(this._a, (this._a[7] ? b.utc(this._a) : b(this._a)).toArray()) : !isNaN(this._d.getTime())
        },
        utc: function () {
            return this._isUTC = !0, this
        },
        local: function () {
            return this._isUTC = !1, this
        },
        format: function (a) {
            return T(this, a ? a : b.defaultFormat)
        },
        add: function (a, c) {
            var d = c ? b.duration(+c, a) : b.duration(a);
            return L(this, d, 1), this
        },
        subtract: function (a, c) {
            var d = c ? b.duration(+c, a) : b.duration(a);
            return L(this, d, -1), this
        },
        diff: function (a, c, e) {
            var f = this._isUTC ? b(a).utc() : b(a).local(),
                g = (this.zone() - f.zone()) * 6e4,
                h = this._d - f._d - g,
                i = this.year() - f.year(),
                j = this.month() - f.month(),
                k = this.date() - f.date(),
                l;
            return c === "months" ? l = i * 12 + j + k / 30 : c === "years" ? l = i + (j + k / 30) / 12 : l = c === "seconds" ? h / 1e3 : c === "minutes" ? h / 6e4 : c === "hours" ? h / 36e5 : c === "days" ? h / 864e5 : c === "weeks" ? h / 6048e5 : h, e ? l : d(l)
        },
        from: function (a, c) {
            return b.duration(this.diff(a)).lang(this._lang).humanize(!c)
        },
        fromNow: function (a) {
            return this.from(b(), a)
        },
        calendar: function () {
            var a = this.diff(b().sod(), "days", !0),
                c = this.lang().calendar,
                d = c.sameElse,
                e = a < -6 ? d : a < -1 ? c.lastWeek : a < 0 ? c.lastDay : a < 1 ? c.sameDay : a < 2 ? c.nextDay : a < 7 ? c.nextWeek : d;
            return this.format(typeof e == "function" ? e.apply(this) : e)
        },
        isLeapYear: function () {
            var a = this.year();
            return a % 4 === 0 && a % 100 !== 0 || a % 400 === 0
        },
        isDST: function () {
            return this.zone() < b([this.year()]).zone() || this.zone() < b([this.year(), 5]).zone()
        },
        day: function (a) {
            var b = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
            return a == null ? b : this.add({
                d: a - b
            })
        },
        startOf: function (a) {
            switch (a.replace(/s$/, "")) {
            case "year":
                this.month(0);
            case "month":
                this.date(1);
            case "day":
                this.hours(0);
            case "hour":
                this.minutes(0);
            case "minute":
                this.seconds(0);
            case "second":
                this.milliseconds(0)
            }
            return this
        },
        endOf: function (a) {
            return this.startOf(a).add(a.replace(/s?$/, "s"), 1).subtract("ms", 1)
        },
        sod: function () {
            return this.clone().startOf("day")
        },
        eod: function () {
            return this.clone().endOf("day")
        },
        zone: function () {
            return this._isUTC ? 0 : this._d.getTimezoneOffset()
        },
        daysInMonth: function () {
            return b.utc([this.year(), this.month() + 1, 0]).date()
        },
        lang: function (b) {
            return b === a ? Q(this) : (this._lang = b, this)
        }
    };
    for (e = 0; e < y.length; e++) _(y[e].toLowerCase(), y[e]);
    _("year", "FullYear"), b.duration.fn = I.prototype = {
        weeks: function () {
            return J(this.days() / 7)
        },
        valueOf: function () {
            return this._milliseconds + this._days * 864e5 + this._months * 2592e6
        },
        humanize: function (a) {
            var b = +this,
                c = this.lang().relativeTime,
                d = $(b, !a, this.lang()),
                e = b <= 0 ? c.past : c.future;
            return a && (typeof e == "function" ? d = e(d) : d = e.replace(/%s/i, d)), d
        },
        lang: b.fn.lang
    };
    for (e in z) z.hasOwnProperty(e) && (bb(e, z[e]), ab(e.toLowerCase()));
    bb("Weeks", 6048e5), h && (module.exports = b), typeof ender == "undefined" && (this.moment = b), typeof define == "function" && define.amd && define("moment", [], function () {
        return b
    })
}).call(this);
var MD5 = function (string) {
    function RotateLeft(lValue, iShiftBits) {
        return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
    }

    function AddUnsigned(lX, lY) {
        var lX4, lY4, lX8, lY8, lResult;
        lX8 = (lX & 0x80000000);
        lY8 = (lY & 0x80000000);
        lX4 = (lX & 0x40000000);
        lY4 = (lY & 0x40000000);
        lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
        if (lX4 & lY4) {
            return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
        }
        if (lX4 | lY4) {
            if (lResult & 0x40000000) {
                return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
            } else {
                return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
            }
        } else {
            return (lResult ^ lX8 ^ lY8);
        }
    }

    function F(x, y, z) {
        return (x & y) | ((~x) & z);
    }

    function G(x, y, z) {
        return (x & z) | (y & (~z));
    }

    function H(x, y, z) {
        return (x ^ y ^ z);
    }

    function I(x, y, z) {
        return (y ^ (x | (~z)));
    }

    function FF(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function GG(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function HH(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function II(a, b, c, d, x, s, ac) {
        a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
        return AddUnsigned(RotateLeft(a, s), b);
    };

    function ConvertToWordArray(string) {
        var lWordCount;
        var lMessageLength = string.length;
        var lNumberOfWords_temp1 = lMessageLength + 8;
        var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64;
        var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
        var lWordArray = Array(lNumberOfWords - 1);
        var lBytePosition = 0;
        var lByteCount = 0;
        while (lByteCount < lMessageLength) {
            lWordCount = (lByteCount - (lByteCount % 4)) / 4;
            lBytePosition = (lByteCount % 4) * 8;
            lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
            lByteCount++;
        }
        lWordCount = (lByteCount - (lByteCount % 4)) / 4;
        lBytePosition = (lByteCount % 4) * 8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
        lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
        lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
        return lWordArray;
    };

    function WordToHex(lValue) {
        var WordToHexValue = "",
            WordToHexValue_temp = "",
            lByte, lCount;
        for (lCount = 0; lCount <= 3; lCount++) {
            lByte = (lValue >>> (lCount * 8)) & 255;
            WordToHexValue_temp = "0" + lByte.toString(16);
            WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length - 2, 2);
        }
        return WordToHexValue;
    };

    function Utf8Encode(string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) {
                utftext += String.fromCharCode(c);
            } else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    };
    var x = Array();
    var k, AA, BB, CC, DD, a, b, c, d;
    var S11 = 7,
        S12 = 12,
        S13 = 17,
        S14 = 22;
    var S21 = 5,
        S22 = 9,
        S23 = 14,
        S24 = 20;
    var S31 = 4,
        S32 = 11,
        S33 = 16,
        S34 = 23;
    var S41 = 6,
        S42 = 10,
        S43 = 15,
        S44 = 21;
    string = Utf8Encode(string);
    x = ConvertToWordArray(string);
    a = 0x67452301;
    b = 0xEFCDAB89;
    c = 0x98BADCFE;
    d = 0x10325476;
    for (k = 0; k < x.length; k += 16) {
        AA = a;
        BB = b;
        CC = c;
        DD = d;
        a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
        d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
        c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
        b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
        a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
        d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
        c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
        b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
        a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
        d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
        c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
        b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
        a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
        d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
        c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
        b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
        a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
        d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
        c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
        b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
        a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
        d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
        c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
        b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
        a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
        d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
        c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
        b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
        a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
        d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
        c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
        b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
        a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
        d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
        c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
        b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
        a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
        d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
        c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
        b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
        a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
        d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
        c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
        b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
        a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
        d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
        c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
        b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
        a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
        d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
        c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
        b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
        a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
        d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
        c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
        b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
        a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
        d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
        c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
        b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
        a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
        d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
        c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
        b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
        a = AddUnsigned(a, AA);
        b = AddUnsigned(b, BB);
        c = AddUnsigned(c, CC);
        d = AddUnsigned(d, DD);
    }
    var temp = WordToHex(a) + WordToHex(b) + WordToHex(c) + WordToHex(d);
    return temp.toLowerCase();
}
var JSON;
if (!JSON) {
    JSON = {};
}
(function () {
    'use strict';

    function f(n) {
        return n < 10 ? '0' + n : n;
    }
    if (typeof Date.prototype.toJSON !== 'function') {
        Date.prototype.toJSON = function (key) {
            return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' +
                f(this.getUTCMonth() + 1) + '-' +
                f(this.getUTCDate()) + 'T' +
                f(this.getUTCHours()) + ':' +
                f(this.getUTCMinutes()) + ':' +
                f(this.getUTCSeconds()) + 'Z' : null;
        };
        String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }
    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap, indent, meta = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"': '\\"',
            '\\': '\\\\'
        }, rep;

    function quote(string) {
        escapable.lastIndex = 0;
        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
            var c = meta[a];
            return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
        }) + '"' : '"' + string + '"';
    }

    function str(key, holder) {
        var i, k, v, length, mind = gap,
            partial, value = holder[key];
        if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }
        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }
        switch (typeof value) {
        case 'string':
            return quote(value);
        case 'number':
            return isFinite(value) ? String(value) : 'null';
        case 'boolean':
        case 'null':
            return String(value);
        case 'object':
            if (!value) {
                return 'null';
            }
            gap += indent;
            partial = [];
            if (Object.prototype.toString.apply(value) === '[object Array]') {
                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }
                v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }
            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    if (typeof rep[i] === 'string') {
                        k = rep[i];
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {
                for (k in value) {
                    if (Object.prototype.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }
            v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }
    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {
            var i;
            gap = '';
            indent = '';
            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }
            } else if (typeof space === 'string') {
                indent = space;
            }
            rep = replacer;
            if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }
            return str('', {
                '': value
            });
        };
    }
    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {
            var j;

            function walk(holder, key) {
                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.prototype.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }
            text = String(text);
            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }
            if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
                j = eval('(' + text + ')');
                return typeof reviver === 'function' ? walk({
                    '': j
                }, '') : j;
            }
            throw new SyntaxError('JSON.parse');
        };
    }
}());
(function ($) {
    $.fn.autocomplete = function (idField, module) {
        var idFieldEl = $("#" + idField);
        var self = this;
        this.unbind('keyup');
        this.bind('keyup', function () {
            var query = self.val();
            var ul = $("#" + self.attr('name') + '-suggestions');
            if (query.length == 0) {
                ul.empty();
                idFieldEl.val('');
                return;
            }
            idFieldEl.val('');
            var nameField = "name";
            if (module == 'Users') {
                nameField = 'full_name';
            }
            var autocompleteJson = {
                "form": "EditView",
                "method": "query",
                "modules": [module],
                "group": "or",
                "field_list": [nameField, "id"],
                "populate_list": ["EditView_account_name", "account_id"],
                "conditions": [{
                    "name": "name",
                    "op": "like_custom",
                    "end": "%",
                    "value": ""
                }],
                "required_list": ["account_id"],
                "order": nameField,
                "limit": "20",
                "no_match_text": "No Match"
            };
            var autocompleteJsonSting = JSON.stringify(autocompleteJson, null, 2);
            App.restCall('getMobileQS', {
                data: {
                    data: autocompleteJsonSting,
                    query: query
                },
                success: function (response) {
                    if (typeof response.data == 'undefined') {
                        return;
                    }
                    response = JSON.parse(response.data);
                    ul.empty();
                    ul.show();
                    $.each(response.fields, function (i, row) {
                        $("<li>").attr("data-id", row.id).attr("data-name", row[nameField]).click(function () {
                            self.val($(this).attr("data-name"));
                            idFieldEl.val($(this).attr("data-id"));
                            ul.hide();
                        }).html(row[nameField]).appendTo(ul);
                    });
                    ul.listview("refresh");
                },
                error: function () {}
            });
        });
    }
})(jQuery);
(function () {
    "use strict"
    this.Application = function (data) {
        this.sugarUrl = data.sugarUrl;
        this.apiUrl = data.apiUrl;
        this.name = data.name;
        this.templateLoader = new root.TemplateLoader({
            useCache: data.templateCaching || true
        });
        this.preferences = new root.Preferences();
        this.flav = 'lite';
        var storedFlav = this.getPreference('flav');
        if (storedFlav) {
            this.flav = storedFlav;
        }
        this.flav = data.flav || this.flav;
        this.modelList = [];
        var storedModelList = this.getPreference('modelList');
        if (storedModelList) {
            this.modelList = storedModelList;
        }
        this.modelList = data.modelList || this.modelList;
        this.superView = new root.SuperView(this);
        this.superView.initModuleCss();
        this.jsCaching = data.jsCaching || true;
        this.setup();
        this.language = new root.Language();
        this.setupLanguage();
        window['Document'] = new Object();
    };
    _.extend(this.Application.prototype, {
        jsCaching: true,
        modelList: [],
        flav: false,
        router: null,
        onMobile: false,
        ajaxErrorMessage: "Ajax error occured.",
        getCollectionName: function (moduleName) {
            if (typeof this.modelList[moduleName] == 'undefined') {
                return false;
            }
            return this.modelList[moduleName].plural;
        },
        getModelName: function (moduleName) {
            if (typeof this.modelList[moduleName] == 'undefined') {
                return false;
            }
            if (this.modelList[moduleName].singular) {
                return this.modelList[moduleName].singular;
            }
            return false;
        },
        templateLoader: null,
        sessionId: '',
        sugarUrl: '',
        apiUrl: '',
        name: 'JetMobile',
        preferences: {},
        _dateTime: null,
        setupLanguage: function () {
            if (this.getPreference('userLanguage')) {
                this.language.setLanguage(this.getPreference('userLanguage'));
            }
            if (this.getPreference('languageList')) {
                this.language.setLanguageList(this.getPreference('languageList'));
            }
        },
        getDateTime: function () {
            if (!this._dateTime) {
                this.include('js/datetime.min.js');
                this._dateTime = new root.DateTime();
                if (this.getPreference('dateFormat') && this.getPreference('timeFormat')) {
                    this._dateTime.setFormats(this.getPreference('dateFormat'), this.getPreference('timeFormat'));
                    this._dateTime.setTimeZoneOffset(this.getPreference('timeZoneOffset'));
                }
            }
            return this._dateTime;
        },
        setup: function () {
            $.ajaxSetup({
                url: this.apiUrl,
                dataType: "json",
                data: {
                    input_type: "JSON",
                    response_type: "JSON"
                }
            });
            var self = this;
            $(document).ajaxError(function (event, jqXHR, ajaxSettings, thrownError) {
                var message;
                if (event === 'timeout') {
                    message = "No response from server.";
                    self.superView.showContentError(message);
                }
                if (typeof jqXHR.noError != 'undefined' && jqXHR.noError) {
                    if (typeof jqXHR.errorMessage != 'undefined') {
                        self.superView.showContentError(jqXHR.errorMessage);
                    }
                    return;
                }
                if (ajaxSettings.dataType != 'script') {
                    if (jqXHR.status == 404) {
                        message = '404 error';
                    } else if (jqXHR.status == 0) {
                        message = 'No response from server.';
                    } else {
                        message = self.ajaxErrorMessage;
                    }
                    self.superView.showContentError(message);
                }
            });
            if (this.onMobile) {
                this.superView.initFastClicks();
            }
        },
        getSessionId: function () {
            var stored = localStorage.getItem('sessionId');
            if (stored) {
                this.sessionId = stored;
            }
            if (this.sessionId) {
                return this.sessionId;
            }
            return false;
        },
        setSessionId: function (sessionId) {
            localStorage.setItem('sessionId', sessionId);
            this.sessionId = sessionId;
        },
        clearPreferences: function () {
            this.preferences.clear();
        },
        getPreference: function (name) {
            return this.preferences.get(name);
        },
        setPreference: function (name, value) {
            return this.preferences.set(name, value);
        },
        login: function (userName, password, callback) {
            if (typeof userName == 'undefined') {
                userName = document.loginForm.userName.value;
            }
            if (typeof password == 'undefined') {
                password = document.loginForm.password.value;
            }
            var data = {
                user_auth: {
                    user_name: userName,
                    password: password
                }
            };
            var self = this;
            this.restCall('login', {
                data: data,
                type: 'POST',
                success: function (data) {
                    if (data.number == '10') {
                        self.superView.showLoginForm();
                        self.superView.showLoginError(data.description);
                        return;
                    }
                    if (typeof data.id != 'undefined') {
                        self.setSessionId(data.id);
                        self.setPreference('dateFormat', data.dateFormat);
                        self.setPreference('timeFormat', data.timeFormat);
                        self.setPreference('timeZoneOffset', data.timeZoneOffset);
                        if (self._dateTime) {
                            self._dateTime.setFormats(data.dateFormat, data.timeFormat);
                            self._dateTime.setTimeZoneOffset(data.timeZoneOffset);
                        }
                        self.setPreference('userId', data.name_value_list.user_id.value);
                        self.setPreference('userName', data.name_value_list.user_name.value);
                        self.setPreference('userIsAdmin', data.name_value_list.user_is_admin.value);
                        var userLanguage;
                        if (localStorage.getItem('userLanguage')) {
                            userLanguage = localStorage.getItem('userLanguage');
                        } else {
                            userLanguage = data.name_value_list.user_language.value;
                        }
                        self.setPreference('userLanguage', userLanguage);
                        self.setPreference('languageList', data.languageList);
                        self.setupLanguage();
                        self.setPreference('flav', data.flav);
                        self.flav = data.flav;
                        self.setPreference('modelList', data.modelList);
                        self.modelList = data.modelList;
                        self.superView.initModuleCss();
                        localStorage.setItem('userName', userName);
                        localStorage.setItem('password', password);
                        self.superView.hideLoginForm();
                        if (typeof callback != 'undefined') {
                            callback.call(this);
                        } else {
                            self.run();
                        }
                    }
                },
                error: function () {
                    self.superView.showLoginError(self.ajaxErrorMessage);
                }
            });
        },
        logout: function () {
            $.ajax({
                data: {
                    method: 'logout'
                },
                dataType: 'text',
                success: function () {}
            });
            this.sessionId = '';
            this.clearPreferences();
            localStorage.removeItem('userName');
            localStorage.removeItem('password');
            this.superView.showLoginForm();
            this.setSessionId('');
            this.stop();
        },
        restCall: function (method, params) {
            var success = typeof params.success != 'undefined' ? params.success : false;
            var error = typeof params.error != 'undefined' ? params.error : false;
            var restData = {};
            if (this.sessionId && method != 'login') {
                restData.session = this.sessionId;
            }
            if (typeof params.data != 'undefined') {
                $.each(params.data, function (i, v) {
                    restData[i] = params.data[i];
                });
            }
            var restString = JSON.stringify(restData, null, 2);
            var data = {
                method: method,
                rest_data: restString
            };
            var ajaxParams = {
                data: data
            }
            if (typeof params.type != 'undefined') {
                ajaxParams.type = params.type;
            } else {
                ajaxParams.type = 'GET';
            }
            var self = this;
            if (success) {
                ajaxParams.success = function (data, textStatus, jqXHR) {
                    if (typeof data.number != 'undefined' && data.number == 40) {
                        alert('Access denied');
                        $.mobile.hidePageLoadingMsg();
                        return false;
                    }
                    if (typeof data.number != 'undefined' && data.number == 11) {
                        if (localStorage.getItem('userName')) {
                            self.login(localStorage.getItem('userName'), localStorage.getItem('password'))
                        } else {
                            self.logout();
                            self.superView.showLoginForm();
                        }
                        return false;
                    }
                    return success(data, textStatus, jqXHR);
                }
            }
            if (error) {
                ajaxParams.error = error;
            } else {
                ajaxParams.error = function () {
                    console.error('Ajax error occured.');
                }
            }
            return $.ajax(ajaxParams);
        },
        nameValueListToJson: function (list) {
            var object = {};
            $.each(list, function (i, v) {
                object[v.name] = v.value;
            });
            return object;
        },
        convertEntryList: function (list) {
            var arr = [];
            var self = this;
            $.each(list, function (i, v) {
                arr.push(self.nameValueListToJson(v.name_value_list));
            });
            return arr;
        },
        renderTemplate: function (tplName, params, url) {
            var url = (typeof url != 'undefined') ? url : false;
            var tplContents = this.templateLoader.load(tplName, url);
            return _.template(tplContents, params);
        },
        stop: function () {
            Backbone.history.stop();
        },
        run: function () {
            var viewHelper = new root.ViewHelper({
                language: this.language,
                app: this
            });
            this.router = new root.Router({
                modelFactory: new ModelFactory,
                collectionFactory: new root.CollectionFactory,
                viewFactory: new root.ViewFactory(viewHelper, {
                    onMobile: this.onMobile
                }),
                preferences: this.preferences
            });
            try {
                Backbone.history.start();
            } catch (err) {
                Backbone.history.loadUrl();
            }
        },
        include: function (path, options) {
            var key = 'script!' + path;
            var thisObject = root;
            if (options != undefined && 'self' in options) {
                thisObject = options.self;
            }
            if (this.jsCaching) {
                var cachedInLocalStorage = localStorage.getItem(key);
                if (cachedInLocalStorage != null) {
                    eval.call(thisObject, cachedInLocalStorage);
                    return;
                }
            }
            var self = this;
            var ajaxOptions = {
                url: path,
                async: false,
                cache: false,
                type: 'GET',
                dataType: 'text',
                success: function (script) {
                    eval.call(thisObject, script);
                    if (self.jsCaching) {
                        localStorage.setItem(key, script);
                        var t = localStorage.getItem(key);
                    } else {
                        if (localStorage.getItem(key)) {
                            localStorage.clear(key);
                        }
                    }
                },
                error: function () {
                    console.error("Error occured while loading " + path);
                }
            };
            if (typeof options != 'undefined') {
                _.each(options, function (value, key) {
                    ajaxOptions[key] = options[key];
                });
            }
            $.ajax(ajaxOptions);
        },
        getBaseUrl: function (url) {
            var m = url.match(/(http|https):\/\/(www\.)?(.[^/:]+)/);
            return m[1] + '://' + m[3];
        },
        getSugarUrl: function (url) {
            var indexOfSharp = url.indexOf("#");
            if (indexOfSharp > -1) {
                url = url.substr(0, indexOfSharp - 1);
            }
            if (url.substr(-1) == '/') {
                url = url.substr(0, url.length - 1);
            }
            if (url.substr(-2) == '/m') {
                url = url.substr(0, url.length - 2);
            }
            return url;
        },
        clearCache: function () {
            var re = new RegExp('^' + this.preferences.prefix + '-');
            var ignore = ['sessionId', 'userName', 'password', 'userLanguage']
            for (var key in localStorage) {
                if (!re.test(key) && $.inArray(key, ignore) == -1) {
                    delete localStorage[key];
                }
            }
        },
        clearLocalStorage: function () {
            for (var key in localStorage) {
                delete localStorage[key];
            }
        },
        translate: function (key, module) {
            return this.language.translate(key, module);
        }
    }, Backbone.Events);
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.Language = function () {
        this.data = {};
    };
    _.extend(this.Language.prototype, {
        language: 'en_us',
        languageList: {
            en_us: 'English (US)'
        },
        setLanguage: function (language) {
            this.language = language;
        },
        setLanguageList: function (languageList) {
            this.languageList = languageList;
        },
        load: function (module, moduleData) {
            this.data[module] = moduleData;
        },
        translate: function (key, module) {
            if (typeof module == 'undefined' || module == false) {
                var module = 'app';
            }
            if (typeof this.data[module] == 'undefined') {
                var url;
                if (module == 'frontend') {
                    url = 'language/' + this.language + '.js';
                } else {
                    url = App.sugarUrl + 'index.php?entryPoint=getMobileLanguage&language=' + this.language + '&module=' + module;
                }
                var self = this;
                App.include(url, {
                    error: function () {
                        self.data[module] = {};
                    }
                });
            }
            var notLoaded = (typeof this.data[module] == 'undefined' || typeof this.data[module][key] == 'undefined');
            if (module != 'app' && notLoaded) {
                return this.translate(key, 'app');
            }
            if (notLoaded) {
                return '';
            }
            if (module != 'appList') {
                var str = new String(this.data[module][key]);
                if (str.slice(-1) == ':') {
                    str = str.substring(0, str.length - 1);
                }
                return str;
            } else {
                return this.data[module][key];
            }
        },
        translateEnum: function (key, dom) {
            var options = this.translate(dom, 'appList');
            if (typeof options[key] == 'undefined') {
                return '';
            }
            return options[key];
        }
    });
}).call(this);
(function () {
    "use strict"
    this.Preferences = function () {
        this.preferences = {};
    };
    _.extend(this.Preferences.prototype, {
        prefix: 'pref',
        clear: function () {
            this.preferences = {};
            var reTxt = '^' + this.prefix + '-';
            var re = new RegExp(reTxt);
            for (var key in localStorage) {
                if (re.test(key)) {
                    delete localStorage[key];
                }
            }
        },
        get: function (name, defaultValue) {
            if (typeof this.preferences[name] != 'undefined') {
                return this.preferences[name];
            } else {
                var stored = localStorage.getItem(this.prefix + '-' + name);
                if (stored) {
                    var str = stored;
                    if (stored[0] == "{" || stored[0] == "[") {
                        try {
                            str = JSON.parse(stored);
                        } catch (error) {
                            str = stored;
                        }
                        stored = str;
                    }
                    this.preferences[name] = stored;
                    return stored;
                }
            }
            if (typeof defaultValue != 'undefined') {
                return defaultValue;
            }
            return null;
        },
        set: function (name, value) {
            this.preferences[name] = value;
            if (value instanceof Object) {
                value = JSON.stringify(value);
            }
            localStorage.setItem(this.prefix + '-' + name, value);
        }
    });
}).call(this);
(function () {
    "use strict"
    this.ViewHelper = function (params) {
        this.language = params.language;
        this.getDateTime = function () {
            return params.app.getDateTime();
        }
    };
    _.extend(this.ViewHelper.prototype, {
        number: {
            format: function (number) {
                var nStr;
                if (number == '') {
                    return '';
                }
                nStr = parseFloat(number).toFixed(2) + '';
                var x = nStr.split('.');
                var x1 = x[0];
                var x2 = x.length > 1 ? '.' + x[1] : '';
                var rgx = /(\d+)(\d{3})/;
                while (rgx.test(x1)) {
                    x1 = x1.replace(rgx, '$1' + ' ' + '$2');
                }
                return x1 + x2;
            },
            formatForEdit: function (number) {
                var nStr;
                if (number == '') {
                    return '';
                }
                return parseFloat(number).toFixed(2);
            }
        },
        language: null,
        string: function (key) {
            var translated = this.language.translate(key, 'frontend');
            if (!translated) {
                return key;
            }
            return translated;
        },
        translate: function (key, module) {
            return this.language.translate(key, module);
        },
        getHtmlOptions: function (key, dom) {
            var options;
            if (typeof dom == 'string') {
                options = this.translate(dom, 'appList');
            } else {
                options = dom;
            }
            var html = '';
            _.each(options, function (translated, k) {
                html += '<option value="' + k + '" ' + ((key == k) ? 'selected' : '') + '>' + translated + '</option>';
            });
            return html;
        },
        parseMultienumString: function (string) {
            return string.split('^').join('').split(',');
        },
        getHtmlOptionsMulti: function (keyString, dom) {
            var selectedKeys = this.parseMultienumString(keyString);
            var html = '';
            var options = this.translate(dom, 'appList');
            _.each(options, function (translated, k) {
                html += '<option value="' + k + '" ' + ((selectedKeys.indexOf(k) != -1) ? 'selected' : '') + '>' + translated + '</option>';
            });
            return html;
        },
        getHtmlMultienumValues: function (keyString, dom) {
            var selectedKeys = this.parseMultienumString(keyString);
            var values = new Array();
            var options = this.translate(dom, 'appList');
            _.each(options, function (translated, k) {
                if (selectedKeys.indexOf(k) > -1) {
                    values.push(translated);
                }
            });
            return values.join(", ");
        }
    });
}).call(this);
(function () {
    "use strict"
    this.ViewFactory = function (helper, options) {
        this.helper = helper;
        if (typeof options == 'undefined') {
            var options = {};
        }
        this.onMobile = options.onMobile || false;
    };
    _.extend(this.ViewFactory.prototype, {
        helper: null,
        create: function (view, params) {
            var viewClass = view + 'View';
            this.include(viewClass);
            if (typeof params == 'undefined') {
                var params = {};
            }
            params['helper'] = this.helper;
            params['onMobile'] = this.onMobile;
            var view = new window[viewClass](params);
            return view;
        },
        include: function (viewClass) {
            if (typeof window[viewClass] == 'undefined') {
                App.include('jetMobile/views/' + viewClass + '.js');
            }
        }
    });
}).call(this);
(function () {
    "use strict"
    this.TemplateLoader = function (params) {
        this.useCache = params.useCache;
    };
    this.TemplateLoader.prototype.useCache = false;
    this.TemplateLoader.prototype.cache = {};
    this.TemplateLoader.prototype.load = function (tplName, url) {
        var key = 'template!' + tplName;
        if (typeof this.cache[tplName] != 'undefined') {
            return this.cache[tplName];
        } else {
            if (this.useCache) {
                var cachedInLocalStorage = localStorage.getItem(key);
                if (cachedInLocalStorage != null) {
                    return cachedInLocalStorage;
                }
            }
            var data = '';
            var self = this;
            if (typeof url == 'undefined' || url == false) {
                var url = "tpls/" + tplName + ".tpl";
            }
            $.ajax({
                url: url,
                async: false,
                cache: false,
                dataType: 'html',
                success: function (tplData) {
                    self.cache[tplName] = tplData;
                    if (self.useCache) {
                        localStorage.setItem(key, tplData);
                    } else {
                        if (localStorage.getItem(key)) {
                            localStorage.clear(key);
                        }
                    }
                    data = tplData;
                }
            });
            return data;
        }
    }
}).call(this);
(function () {
    "use strict"
    this.Router = Backbone.Router.extend({
        routes: {
            "home": "homeAction",
            "quickCreate": "quickCreateAction",
            "settings": "settingsAction",
            "clearCache": "clearCacheAction",
            "reset": "resetAction",
            "Calendar": "calendarAction",
            "Calendar/": "calendarAction",
            "Calendar/:viewType": "calendarAction",
            "Calendar/:viewType/": "calendarAction",
            "Calendar/:viewType/:dateStart": "calendarAction",
            ":module/create": "editAction",
            ":module/edit/:id": "editAction",
            ":module/create/from:parentModule/:parentId/:link": "createFromSubpanelAction",
            ":module/detail/:id": "detailAction",
            ":module/detail/:id/subpanel/:link": "subpanelAction",
            ":module/detail/:id/subpanel/:link/:offset": "subpanelAction",
            ":module": "listAction",
            ":module/": "listAction",
            ":module/:offset": "listAction",
            "*actions": "homeAction"
        },
        modelFactory: null,
        collectionFactory: null,
        viewFactory: null,
        currentView: null,
        preferences: null,
        initialize: function (options) {
            this.modelFactory = options.modelFactory;
            this.collectionFactory = options.collectionFactory;
            this.viewFactory = options.viewFactory;
            this.preferences = options.preferences;
        },
        createView: function (viewName, params) {
            if (this.currentView) {
                this.currentView.close();
            }
            this.currentView = this.viewFactory.create(viewName, params);
            return this.currentView;
        },
        calendarAction: function (viewType, dateFrom) {
            var calendar = this.collectionFactory.create('Calendar');
            calendar.setDateTime(App.getDateTime());
            if (typeof viewType != 'undefined') {
                calendar.setViewType(viewType);
            }
            if (typeof dateFrom != 'undefined') {
                calendar.setDate(dateFrom);
            }
            var calendarView = this.createView('Calendar', {
                collection: calendar
            });
            var rendered = false;
            calendar.on('reset', function () {
                if (!rendered) {
                    calendarView.render();
                    rendered = true;
                } else {
                    calendarView.renderRows();
                }
            }, this);
            calendar.fetch();
            calendarView.on('update', function () {
                this.navigate('#Calendar/' + calendar.viewType + '/' + calendar.date, {
                    trigger: false
                });
            }, this);
        },
        listAction: function (module, offset) {
            if (typeof offset != 'undefined' && isNaN(parseInt(offset))) {
                alert('Error');
                return false;
            }
            var collection = this.collectionFactory.create(module);
            var offset = typeof offset == 'undefined' ? 0 : parseInt(offset);
            collection.setOffset(offset);
            if (this.preferences.get('entriesPerPage')) {
                collection.setLimit(this.preferences.get('entriesPerPage'));
            }
            var searchForm = new SearchForm(collection);
            var query = searchForm.getStoredQuery();
            if (query) {
                collection.setQuery(query);
            }
            var listView = this.createView('List', {
                collection: collection,
                searchForm: searchForm
            });
            var rendered = false;
            collection.on('reset', function () {
                if (!rendered) {
                    listView.render();
                    rendered = true;
                } else {
                    listView.renderRows();
                }
            }, this);
            collection.fetch();
            listView.on('update', function () {
                this.navigate('#' + module + '/' + collection.offset, {
                    trigger: false
                });
            }, this);
        },
        subpanelAction: function (module, id, link, offset) {
            var model = this.modelFactory.create(module, id);
            if (typeof SubpanelController == 'undefined') {
                App.include('jetMobile/SubpanelController.js');
            }
            var subpanelController = new SubpanelController(model);
            var relatedModule = subpanelController.getRelatedModule(link);
            var collection = this.collectionFactory.create(relatedModule);
            collection.isRelated = true;
            var offset = typeof offset == 'undefined' ? 0 : parseInt(offset);
            collection.setOffset(offset);
            if (this.preferences.get('entriesPerPage')) {
                collection.setLimit(this.preferences.get('entriesPerPage'));
            }
            collection.setRelatedParams({
                moduleName: module,
                moduleId: id,
                linkFieldName: link
            });
            var listView = this.createView('SubpanelList', {
                collection: collection
            });
            var rendered = false;
            collection.on('reset', function () {
                if (!rendered) {
                    listView.render();
                    rendered = true;
                } else {
                    listView.renderRows();
                }
            }, this);
            collection.fetch();
            listView.on('update', function () {
                this.navigate('#' + module + '/detail/' + id + '/subpanel/' + link + '/' + collection.offset, {
                    trigger: false
                });
            }, this);
        },
        detailAction: function (module, id) {
            var model = this.modelFactory.create(module);
            if (model == null) {
                this._moduleNotSupported(module);
                return;
            }
            model.id = id;
            var detailView = this.createDetailView(model);
            model.on('change', function () {
                detailView.render();
                if (model.get('deleted') != 1) {
                    this._processSubpanels(model);
                }
            }, this);
            model.fetch();
        },
        createDetailView: function (model) {
            var detailView = this.createView('Detail', {
                model: model
            });
            detailView.on('delete', function () {
                this._deleteHandler(model);
            }, this);
            return detailView;
        },
        _createEditView: function (model) {
            var editView = this.createView('Edit', {
                model: model
            });
            return editView;
        },
        _processSubpanels: function (model) {
            if (typeof SubpanelController == 'undefined') {
                App.include('jetMobile/SubpanelController.js');
            }
            var subpanelController = new SubpanelController(model, this.viewFactory);
            subpanelController.process();
        },
        createFromSubpanelAction: function (module, parentModule, parentId, link) {
            this.editAction(module, null, parentModule, parentId, link);
        },
        editAction: function (module, id, parentModule, parentId, link) {
            var model = this.modelFactory.create(module);
            var editView = this._createEditView(model);
            if (typeof id != 'undefined' && id != '' && id != null) {
                model.id = id;
                model.fetch();
                model.on("change", function () {
                    editView.render();
                    model.off("change");
                });
            } else {
                model.prepareForCreate();
                setTimeout(function () {
                    editView.render();
                }, 50);
            }
            var fromSubpanel = typeof parentModule != 'undefined' && typeof parentId != 'undefined' && typeof link != 'undefined';
            model.on('sync', function () {
                if (model.attributes.id == '' && typeof model.attributes.duplicate != 'undefined' && model.attributes.duplicate) {
                    if (editView.duplicateConfirm()) {
                        model.attributes.ignore_duplicate = true;
                        model.save();
                    } else {
                        $.mobile.hidePageLoadingMsg();
                        $("#save-btn").removeClass('ui-disabled');
                    }
                    return;
                }
                var self = this;
                var navigateToDetailView = function (model) {
                    self.createDetailView(model).render();
                    self._processSubpanels(model);
                    self.navigate('#' + model.module + '/detail/' + model.id, {
                        trigger: false
                    });
                }
                if (!fromSubpanel) {
                    navigateToDetailView(model);
                } else {
                    if (typeof RelationshipHandler == 'undefined') {
                        App.include('jetMobile/RelationshipHandler.js');
                    }
                    var relationshipHandler = new RelationshipHandler();
                    relationshipHandler.on('created', function () {
                        this.navigate('#' + parentModule + '/detail/' + parentId + '/subpanel/' + link, {
                            trigger: true
                        });
                    }, this);
                    relationshipHandler.create(parentModule, parentId, link, model.id);
                }
            }, this);
            editView.on('save', function () {
                model.save();
            }, this);
            editView.on('delete', function () {
                this._deleteHandler(model);
            }, this);
            editView.on('cancel', function () {
                if (model.isNew()) {
                    if (!fromSubpanel) {
                        this.navigate('#' + model.module, {
                            trigger: true
                        });
                    } else {
                        this.navigate('#' + parentModule + '/detail/' + parentId, {
                            trigger: true
                        });
                    }
                } else {
                    this.createDetailView(model).render();
                    this._processSubpanels(model);
                    this.navigate('#' + model.module + '/detail/' + model.id, {
                        trigger: false
                    });
                }
            }, this);
        },
        _deleteHandler: function (model) {
            model.destroy();
            var self = this;
            setTimeout(function () {
                self.navigate('#' + model.module, {
                    trigger: true
                });
            }, 1000);
        },
        quickCreateAction: function () {
            var quickCreateView = this.viewFactory.create('QuickCreate');
            quickCreateView.render();
        },
        settingsAction: function () {
            var settingsView = this.viewFactory.create('Settings', {
                preferences: this.preferences
            });
            settingsView.render();
            var self = this;
            settingsView.on('save', function () {
                localStorage.setItem('userLanguage', settingsView.settings.userLanguage);
                this.preferences.set('entriesPerPage', settingsView.settings.entriesPerPage);
                self.relogin();
            });
        },
        clearCacheAction: function () {
            App.clearCache();
            this.relogin();
        },
        resetAction: function () {
            App.clearLocalStorage();
            this.navigate('#', {
                trigger: false
            });
            App.logout();
        },
        buyAction: function () {
            var buyView = this.viewFactory.create('Buy');
            buyView.render();
        },
        relogin: function () {
            this.navigate('#', {
                trigger: false
            });
            App.login(localStorage.getItem('userName'), localStorage.getItem('password'), function () {
                window.location.reload();
            });
        },
        _moduleNotSupported: function (module) {
            var NoModuleView = this.createView('NoModule', {
                moduleName: module
            });
            NoModuleView.render();
        },
        homeAction: function () {
            var mainMenuView = this.viewFactory.create('MainMenu');
            mainMenuView.render();
        }
    });
    this.Router.prototype.routes[":module/create"] = "buyAction";
    this.Router.prototype.routes[":module/create/from:parentModule/:parentId/:link"] = "buyAction";
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.ModelFactory = function () {};
    _.extend(this.ModelFactory.prototype, {
        create: function (module, id) {
            var modelName = root.App.getModelName(module);
            if (modelName) {
                this.include(module);
                var model = new window[modelName];
                if (typeof id != 'undefined') {
                    model.id = id;
                    model.fetch();
                }
                return model;
            }
            return null;
        },
        include: function (module) {
            var modelName = root.App.getModelName(module);
            if (modelName && (typeof window[modelName] == 'undefined' || Object.keys(window[modelName]).length === 0)) {
                App.include(root.App.sugarUrl + 'm/jetMobile/models/' + root.App.getModelName(module) + '.js');
            }
        }
    });
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.CollectionFactory = function () {};
    _.extend(this.CollectionFactory.prototype, {
        create: function (module) {
            this.include(module);
            var collection = new window[App.getCollectionName(module)];
            return collection;
        },
        include: function (module) {
            ModelFactory.prototype.include(module);
            if (typeof window[App.getCollectionName(module)] == 'undefined') {
                App.include(App.sugarUrl + 'm/jetMobile/collections/' + App.getCollectionName(module) + '.js');
            }
        }
    });
}).call(this);
(function () {
    "use strict"
    this.BaseModel = Backbone.Model.extend({
        module: false,
        type: 'Base',
        get: function (field) {
            var value = Backbone.Model.prototype.get.apply(this, arguments);
            if (typeof value == 'undefined' || value == null) {
                value = '';
            }
            return value;
        },
        parse: function (response) {
            if (typeof response.entry_list != 'undefined') {
                if (typeof response.entry_list[0] != 'undefined') {
                    var obj = App.nameValueListToJson(response.entry_list[0].name_value_list);
                } else {
                    var obj = App.nameValueListToJson(response.entry_list);
                }
            } else {
                var obj = App.nameValueListToJson(response.name_value_list);
            }
            if (typeof response.id != 'undefined') {
                this.id = response.id;
            }
            return obj;
        },
        sync: function (method, model, options) {
            if (method == 'read') {
                var sugarMethod = 'get_entry';
                var params = {
                    data: {
                        module_name: model.module,
                        id: this.id
                    }
                };
                return App.restCall(sugarMethod, _.extend(params, options));
            }
            if (method == 'update' || method == 'create' || method == 'delete') {
                if (method == 'delete') {
                    model.set('deleted', 1);
                }
                var sugarMethod = 'set_entry';
                var successBase = options.success;
                var self = this;
                var params = {
                    data: {
                        module_name: model.module,
                        name_value_list: this.getNameValueList()
                    },
                    type: 'POST',
                    success: function (response) {
                        if (method == 'create') {
                            self.set('id', response.id);
                        }
                        if (typeof response.duplicate != 'undefined' && response.duplicate) {
                            self.attributes.duplicate = true;
                        }
                        successBase(response);
                    }
                };
                options.success = params.success;
                return App.restCall(sugarMethod, _.extend(params, options));
            }
        },
        getNameValueList: function () {
            var nameValueList = {};
            _.each(this.attributes, function (value, key) {
                nameValueList[key] = {
                    name: key,
                    value: value
                };
            });
            if (this.id) {
                nameValueList['id'] = {
                    name: 'id',
                    value: this.id
                };
            }
            return nameValueList;
        },
        prepareForCreate: function () {
            this.attributes.assigned_user_id = App.getPreference('userId');
            this.attributes.assigned_user_name = App.getPreference('userName');
        }
    });
}).call(this);
(function () {
    "use strict"
    this.BaseCollection = Backbone.Collection.extend({
        module: false,
        orderBy: 'date_entered DESC',
        query: "",
        offset: 0,
        limit: 10,
        totalResultCount: 0,
        isRelated: false,
        relatedParams: {},
        initialize: function () {
            if (!this.module) {
                this.module = this.model.prototype.module;
            }
            this.setOffset(this.offset);
            _.bindAll(this, 'sync');
            _.bindAll(this, 'parse');
        },
        setQuery: function (query) {
            this.query = query;
        },
        setOffset: function (offset) {
            this.offset = offset;
            this.trigger('changeOffset');
        },
        setLimit: function (limit) {
            this.limit = limit;
        },
        parse: function (response) {
            if (typeof response.number != 'undefined') {
                if (response.number == 40) {
                    this.trigger('acceessDenied');
                    return;
                }
            }
            this.totalResultCount = response.total_count;
            if (typeof response.parentName != 'undefined') {
                this.relatedParams.parentName = response.parentName;
            }
            this.trigger('afterSync');
            var self = this;
            var entryList = new Array();
            $.each(response.entry_list, function (i) {
                response.entry_list[i] = self.sanitizeRow.call(self, response.entry_list[i]);
                if (i < self.limit) {
                    entryList.push(response.entry_list[i]);
                }
            });
            return entryList;
        },
        sync: function (method, model, options) {
            if (method == 'read') {
                if (!this.isRelated) {
                    var sugarMethod = 'get_entry_list';
                    var params = {
                        data: {
                            module_name: model.module,
                            query: this.query,
                            order_by: this.orderBy,
                            offset: this.offset + '',
                            select_fields: null,
                            link_name_to_fields_array: [],
                            max_results: this.limit,
                            deleted: '0'
                        }
                    };
                } else {
                    var sugarMethod = 'getRelatedEntries';
                    var params = {
                        data: {
                            moduleName: this.relatedParams.moduleName,
                            moduleId: this.relatedParams.moduleId,
                            linkFieldName: this.relatedParams.linkFieldName,
                            orderBy: this.orderBy,
                            offset: this.offset,
                            limit: this.limit
                        }
                    };
                }
                var self = this;
                options['error'] = function (jqXHR, e) {
                    if (jqXHR.responseText.indexOf(App.language.translate('ERR_DB_FAIL')) > -1) {
                        self.reset();
                        self.trigger('reset');
                        jqXHR.noError = true;
                        jqXHR.errorMessage = App.language.translate('ERR_DB_FAIL');
                    }
                }
                return App.restCall(sugarMethod, _.extend(params, options));
            }
        },
        sanitizeRow: function (row) {
            return row;
        },
        setRelatedParams: function (relatedParams) {
            this.relatedParams = relatedParams;
        }
    });
}).call(this);
(function () {
    "use strict"
    this.SuperView = function (app, options) {
        this.app = app;
        this.init();
    };
    _.extend(this.SuperView.prototype, {
        app: null,
        init: function () {},
        showLoginForm: function () {
            if ($("#login").html() == '') {
                $("#login").html(this.app.renderTemplate('Login', {
                    name: this.app.name
                }));
            }
            this.hideLoginError();
            $("#header").hide();
            $("#content").hide().empty();
            $("#footer").hide().empty();
            $("#login").show();
            $("#page").trigger('create');
        },
        hideLoginForm: function () {
            $("#login").hide();
            this.showContent();
        },
        showContent: function () {
            $("#header").show();
            $("#content").show();
            $("#footer").show();
        },
        showLoginError: function (errorMsg) {
            $("#login .error").show().html(errorMsg);
        },
        hideLoginError: function () {
            $("#login .error").hide().empty();
        },
        showContentError: function (message) {
            $(".error").remove();
            $("#content").prepend($('<div class="error" style="margin-bottom: 10px;">' + message + '</div>'));
            $.mobile.hidePageLoadingMsg();
            $.mobile.silentScroll(0);
            $("#content").show();
        },
        initModuleCss: function () {
            if (Object.keys(this.app.modelList).length !== 0) {
                var css = '';
                for (var module in this.app.modelList) {
                    var moduleLower = module.toLowerCase();
                    css += "#module-" + moduleLower + " .ui-icon, .ui-icon-module-" + moduleLower + " {background: url(" + this.app.sugarUrl + "index.php?entryPoint=getImage&imageName=icon_" + module + "_32.gif) no-repeat rgba(255,255, 255, 0.4);}";
                }
                $("<style></style>").appendTo("head").html(css);
            }
        },
        initFastClicks: function () {
            var self = this;
            this.allowClicks = true;
            var disableClicks = function () {
                self.allowClicks = false;
                setTimeout(function () {
                    self.allowClicks = true;
                }, 300);
            }
            $("#content").on('create', function (e) {
                disableClicks();
            });
            $(document).on('touchstart', function (e) {
                if (!self.allowClicks) {
                    e.preventDefault();
                    e.stopPropagation();
                }
            });
            $('body').on('click', 'a', function (e) {
                var href = $(e.currentTarget).attr('href');
                if (typeof href != 'undefined' && href != '' && href != '#') {
                    e.preventDefault();
                }
            });
            $('body').on('touchend', 'a', function (e) {
                if (!self.allowClicks) {
                    e.preventDefault();
                    e.stopPropagation();
                    return;
                }
                var href = $(e.currentTarget).attr('href');
                if (typeof href != 'undefined' && href != '' && href != '#') {
                    if (self.app.router) {
                        disableClicks();
                        self.app.router.navigate(href, {
                            trigger: true
                        });
                        e.preventDefault();
                    }
                }
            });
        },
    });
}).call(this);
(function (Backbone) {
    this.BaseView = Backbone.View.extend({
        el: '#content',
        tpl: '',
        helper: null,
        displayFooter: true,
        isSugarTpl: false,
        module: false,
        onMobile: false,
        initialize: function () {
            this.helper = this.options.helper;
            this.template = $("#" + this.tpl).html();
            if (typeof this.options.footerItems != 'undefined') {
                this.footerItems = this.options.footerItems;
            }
            this.onMobile = this.options.onMobile || false;
            this.showLoadingMessage();
        },
        showLoadingMessage: function () {
            $.mobile.showPageLoadingMsg('a', this.helper.string('Wait...'), true);
        },
        bindEvent: function (selector, action, callback) {
            if (this.onMobile && action == 'click') {
                action = 'touchend';
            }
            var self = this;
            $(window).bind('create', function () {
                $(selector).unbind(action);
                $(selector).bind(action, $.proxy(callback, self));
            });
            this.on('close', function () {
                $(selector).unbind(action);
            });
        },
        params: {},
        footerItems: [],
        render: function () {
            var params = typeof this.params == 'function' ? this.params() : this.params;
            params['helper'] = this.helper;
            var url = false;
            var tpl = this.tpl;
            if (this.module) {
                if (this.isSugarTpl) {
                    url = App.sugarUrl + 'index.php?entryPoint=getMobileTemplate&module=' + this.module + '&view=' + this.tpl;
                }
                tpl = this.module + '/' + this.tpl;
            }
            var tplContents = App.renderTemplate(tpl, params, url);
            this.$el.html(tplContents);
            if (this.displayFooter) {
                if (typeof FooterView == 'undefined') {
                    App.include('jetMobile/views/FooterView.js');
                }
                var footerItems = typeof this.footerItems == 'function' ? this.footerItems() : this.footerItems;
                var footerView = new FooterView({
                    items: footerItems,
                    helper: this.helper
                });
                footerView.render();
            }
            var bar = $("#bar");
            if (bar.html() == '') {
                bar.html(App.renderTemplate('Bar', {
                    helper: this.helper
                }));
                $("#page").trigger('create');
            } else {
                if (this.displayFooter && footerItems.length > 0) {
                    $("#footer").trigger('create');
                }
            }
            App.superView.showContent();
            this.$el.trigger('create');
        },
        scrollToTop: function () {
            var position = $("#content").position();
            $.mobile.silentScroll(position.top);
        },
        close: function () {
            this.trigger('close');
            this.off();
            delete this;
        }
    });
}).call(this, Backbone);
(function () {
    "use strict"
    this.SearchForm = function (collection) {
        this.model = collection.model;
        this.collection = collection;
        this.searchFields = collection.searchFields;
    };
    _.extend(this.SearchForm.prototype, {
        formId: "SearchForm",
        fillStoredSearchFields: function () {
            var searchArray = this._getStoredSearchArray();
            if (searchArray) {
                for (i in searchArray) {
                    var key = searchArray[i].name;
                    var value = searchArray[i].value;
                    var type = searchArray[i].type;
                    var el = $("#search-" + key);
                    var elType = el.attr("type");
                    if (typeof elType == 'undefined') {
                        elType = el.prop("tagName").toLowerCase();
                    }
                    if (el) {
                        switch (elType) {
                        case 'text':
                            el.val(value);
                            break;
                        case 'hidden':
                            el.val(value);
                            break;
                        case 'checkbox':
                            if (value) {
                                el.attr('checked', 'checked').checkboxradio('refresh');
                            }
                            break;
                        case 'select':
                            if (Object.prototype.toString.call(value) === '[object Array]') {
                                var j;
                                for (j in value) {
                                    el.children("option[value='" + value[j] + "']").attr('selected', 'selected');
                                }
                            } else {
                                el.children("option[value='" + value + "']").attr('selected', 'selected')
                            }
                            el.selectmenu('refresh', true);
                            break;
                        }
                    }
                }
            }
        },
        getStoredQuery: function () {
            var searchArray = this._getStoredSearchArray();
            if (searchArray) {
                return this._composeQuery(searchArray);
            }
            return false;
        },
        getQuery: function () {
            var searchArray = this._readFromForm();
            App.setPreference(this.model.prototype.module + '-' + 'searchArray', searchArray);
            return this._composeQuery(searchArray);
        },
        _getStoredSearchArray: function () {
            return App.getPreference(this.model.prototype.module + '-' + 'searchArray');
        },
        _checkIgnore: function (elm) {
            var ignore = false;
            if ($(elm).data("ignore")) {
                ignore = true;
            }
            if ($(elm).data("search-with")) {
                var relatedSearchId = $(elm).data("search-with");
                if ($("#" + relatedSearchId).val() == '') {
                    ignore = true;
                }
            }
            return ignore;
        },
        _getType: function (elm, type) {
            var customType = type;
            if ($(elm).data("custom-type")) {
                var value = $("#search-" + elm.name + '-type').val();
                if (value) {
                    customType = value;
                }
            }
            return customType;
        },
        _readFromForm: function () {
            var self = this;
            var searchArray = new Array();
            $.each($("#" + this.formId + " input[type='text']"), function (i, elm) {
                if (elm.value) {
                    searchArray.push({
                        name: elm.name,
                        value: elm.value,
                        type: self._getType(elm, 'like'),
                        ignore: self._checkIgnore(elm)
                    });
                }
            });
            $.each($("#" + this.formId + " input[type='hidden']"), function (i, elm) {
                if (elm.value) {
                    searchArray.push({
                        name: elm.name,
                        value: elm.value,
                        type: self._getType(elm, 'equals'),
                        ignore: self._checkIgnore(elm)
                    });
                }
            });
            $.each($("#" + this.formId + " input[type='checkbox']"), function (i, elm) {
                var ignore = self._checkIgnore(elm);
                var value = false;
                if (elm.checked) {
                    value = true;
                }
                if (value) {
                    searchArray.push({
                        name: elm.name,
                        value: value,
                        type: 'equals',
                        ignore: ignore
                    });
                }
            });
            $.each($("#" + this.formId + " select:not([multiple])"), function (i, elm) {
                if (elm.value) {
                    searchArray.push({
                        name: elm.name,
                        value: elm.value,
                        type: 'equals',
                        ignore: self._checkIgnore(elm)
                    });
                }
            });
            $.each($("#" + this.formId + " select[multiple]"), function (i, elm) {
                var ignore = self._checkIgnore(elm);
                var values = new Array();
                $.each($(elm).children("option:selected"), function (j, option) {
                    if (option.value != "") {
                        values.push(option.value);
                    }
                });
                searchArray.push({
                    name: elm.name,
                    value: values,
                    type: 'in',
                    ignore: ignore
                });
            });
            return searchArray;
        },
        _fieldToDb: function (key) {
            if (key.indexOf(".") == -1) {
                if (key.indexOf("_c") == -1) {
                    key = this.model.prototype.tableName + "." + key;
                } else {
                    key = this.model.prototype.tableName + "_cstm." + key;
                }
            }
            return key;
        },
        _valueForLike: function (value) {
            if (value.indexOf("%") == -1) {
                value = value + "%";
            }
            return value;
        },
        _composeWherePart: function (field, value, type) {
            var fieldArr = new Array();
            if (typeof this.searchFields[field] != 'undefined' && typeof this.searchFields[field]['db_field'] != 'undefined') {
                for (i in this.searchFields[field]['db_field']) {
                    fieldArr.push(this.searchFields[field]['db_field'][i]);
                }
            } else {
                fieldArr.push(field);
            }
            var partArr = new Array();
            for (i in fieldArr) {
                var key = fieldArr[i];
                var part = '';
                switch (type) {
                case 'equals':
                    part = this._fieldToDb(key) + " = '" + value + "'";
                    break;
                case 'less':
                    part = this._fieldToDb(key) + " < '" + value + "'";
                    break;
                case 'more':
                    part = this._fieldToDb(key) + " > '" + value + "'";
                    break;
                case 'moreOrEquals':
                    part = this._fieldToDb(key) + " >= '" + value + "'";
                    break;
                case 'lessOrEquals':
                    part = this._fieldToDb(key) + " <= '" + value + "'";
                    break;
                case 'like':
                    part = this._fieldToDb(key) + " LIKE '" + this._valueForLike(value) + "'";
                    break;
                case 'in':
                    if (value.length > 0) {
                        var arr = new Array();
                        for (i in value) {
                            arr.push(this._fieldToDb(key) + " = '" + value[i] + "'");
                        }
                        part = "(" + arr.join(" OR ") + ")";
                    }
                    break;
                }
                partArr.push(part);
            }
            var wherePart = partArr.join(" OR ");
            if (partArr.length > 1) {
                wherePart += "(" + wherePart + ")";
            }
            return wherePart;
        },
        _composeQuery: function (searchArray) {
            var tableName = this.model.prototype.tableName;
            var clause = new Array();
            for (i in searchArray) {
                if (typeof searchArray[i].ignore != 'undefined' && searchArray[i].ignore) {
                    continue;
                }
                var key = searchArray[i].name;
                var value = searchArray[i].value;
                var type = searchArray[i].type;
                var part = '';
                switch (key) {
                case 'current_user_only':
                    if (value) {
                        part = this._fieldToDb('assigned_user_id') + " = '" + App.getPreference('userId') + "'";
                    }
                    break;
                case 'name':
                    if (value) {
                        value = this._valueForLike(value);
                        if (this.model.prototype.type == 'Person') {
                            part = "(" + this._fieldToDb('first_name') + " LIKE '" + value + "' OR " + this._fieldToDb('last_name') + " LIKE '" + value + "')";
                        } else {
                            part = this._fieldToDb(key) + " LIKE '" + value + "'";
                        }
                    }
                    break;
                default:
                    if (value) {
                        part = this._composeWherePart(key, value, type);
                    }
                }
                if (part != '') {
                    clause.push(part);
                }
            }
            var query = clause.join(" AND ");
            return query;
        }
    });
}).call(this);
(function () {
    "use strict"
    this.ListView = this.BaseView.extend({
        module: false,
        tpl: 'ListView',
        rowsOnly: false,
        searchForm: null,
        initialize: function () {
            root.BaseView.prototype.initialize.apply(this, arguments);
            this.module = this.collection.module;
            this.collection.on('afterSync', this.calculatePagination, this);
            this.bindEvent("#previous-btn", 'click', function () {
                this.disablePaginationButons();
                this.changeOffset(this.collection.offset - (+this.collection.limit));
                this.showLoadingMessage();
            });
            this.bindEvent("#next-btn", 'click', function () {
                this.disablePaginationButons();
                this.changeOffset(this.collection.offset + (+this.collection.limit));
                this.showLoadingMessage();
            });
            this.bindEvent("#btn-search", 'click', this.searchHandler);
            this.on('close', function () {
                this.collection.off('afterSync');
                this.collection.off('reset');
                delete this.collection;
            }, this);
            if (this.options.searchForm) {
                this.searchForm = this.options.searchForm;
            }
            if (App.flav != 'lite') {
                this.isSugarTpl = true;
            }
        },
        searchHandler: function () {
            this.showLoadingMessage();
            var query = this.searchForm.getQuery();
            this.collection.setQuery(query);
            this.collection.setOffset(0);
            this.collection.fetch();
            this.trigger('update');
        },
        changeOffset: function (offset) {
            this.collection.setOffset(offset);
            this.collection.fetch();
            this.trigger('update');
        },
        disablePaginationButons: function () {
            $("#next-btn, #previous-btn").addClass('ui-disabled');
        },
        pageCount: 0,
        pageNumber: 0,
        calculatePagination: function () {
            this.pageCount = Math.ceil(this.collection.totalResultCount / this.collection.limit);
            this.pageNumber = Math.floor(this.collection.offset / this.collection.limit) + 1;
        },
        footerItems: function () {
            return [{
                type: 'link',
                id: 'previous-btn',
                disabled: (this.pageNumber == 1 || this.pageNumber == 0),
                text: 'Previous',
                icon: 'arrow-l',
            }, {
                type: 'link',
                action: '#' + this.module + '/create',
                text: 'New',
                icon: 'plus',
            }, {
                type: 'link',
                id: 'next-btn',
                disabled: (this.pageCount == this.pageNumber || this.pageCount == 0),
                text: 'Next',
                icon: 'arrow-r',
            }];
        },
        params: function () {
            return {
                collection: this.collection,
                moduleName: this.module,
                rowsOnly: this.rowsOnly,
                header: this.getHeader(),
                paginationData: {
                    pageNumber: this.pageNumber,
                    pageCount: this.pageCount,
                    count: this.collection.length,
                    totalResultCount: this.collection.totalResultCount,
                    string: this.getPaginationString()
                }
            };
        },
        getPaginationString: function () {
            if (this.collection.length == 0) {
                return "";
            }
            var from = this.collection.offset + 1;
            var to = this.collection.offset + this.collection.length;
            return '(' + from + ' - ' + to + ' ' + this.helper.string('of') + ' ' + this.collection.totalResultCount + ')';
        },
        render: function () {
            root.BaseView.prototype.render.apply(this, arguments);
            if (!this.rowsOnly && this.searchForm) {
                this.searchForm.fillStoredSearchFields();
            }
            this.scrollToTop();
        },
        renderRows: function () {
            var el = this.el;
            this.el = '#list-view';
            this.$el = $(this.el);
            this.rowsOnly = true;
            this.render();
            $("#pagination-info").html(this.getPaginationString());
            this.el = el;
            this.$el = $(this.el);
            $("#list-view").listview('refresh');
        },
        getHeader: function () {
            return this.helper.language.translateEnum(this.module, 'moduleList');
        }
    });
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.DetailView = this.BaseView.extend({
        module: false,
        tpl: 'DetailView',
        initialize: function () {
            root.BaseView.prototype.initialize.apply(this, arguments);
            this.module = this.model.module;
            this.bindEvent('#delete-btn', 'click', this.deleteButtonHandler);
            this.on('close', function () {
                this.model.off('change');
                delete this.model;
            }, this);
            if (App.flav != 'lite') {
                this.isSugarTpl = true;
            }
        },
        deleteButtonHandler: function () {
            if (confirm(this.helper.string('Are you sure you want to delete the entry?'))) {
                this.trigger('delete');
            }
        },
        footerItems: function () {
            return [{
                type: 'link',
                action: '#' + this.module + '/edit/' + this.model.id,
                disabled: this.model.get('deleted') == 1,
                text: 'Edit',
                icon: 'gear',
            }, {
                type: 'link',
                action: '#' + this.module,
                text: 'List',
                icon: 'grid',
            }, {
                type: 'link',
                id: 'delete-btn',
                disabled: this.model.get('deleted') == 1,
                text: 'Delete',
                icon: 'delete',
            }];
        },
        params: function () {
            return {
                model: this.model,
                header: this.getHeader()
            };
        },
        render: function () {
            if (this.model.get('deleted') == 1) {
                this.isSugarTpl = false;
                this.module = false;
                this.tpl = 'DeletedEntry';
            }
            root.BaseView.prototype.render.apply(this, arguments);
            if (this.model.get('deleted') != 1) {
                this.$el.append(App.renderTemplate('SubpanelsContainer', {
                    helper: this.helper
                }));
            }
            this.scrollToTop();
        },
        getHeader: function () {
            return '<a href="#' + this.module + '">' + this.helper.language.translateEnum(this.module, 'moduleList') + '</a>' + ' > ' + this.model.get('name');
        }
    });
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.EditView = this.BaseView.extend({
        module: false,
        tpl: 'EditView',
        initialize: function () {
            root.BaseView.prototype.initialize.apply(this, arguments);
            this.module = this.model.module;
            this.bindEvent('#save-btn', 'click', this.saveButtonHandler);
            this.bindEvent('#cancel-btn', 'click', this.cancelButtonHandler);
            this.bindEvent('#delete-btn', 'click', this.deleteButtonHandler);
            this.bindEvent("#EditView input[type='file']", 'change', this.preloadFileHandler);
            this.on('close', function () {
                this.model.off('change');
                this.model.off('sync');
                delete this.model;
            }, this);
            this.files = {};
            if (root.App.flav != 'lite') {
                this.isSugarTpl = true;
            }
            $.validator.messages.required = '' + this.helper.string('This field is required.');
            $.validator.messages.email = '' + this.helper.string('Please enter a valid email address.');
        },
        preloadFileHandler: function (e) {
            var self = this;
            var file = e.target.files[0];
            var fieldName = e.target.name;
            if (file instanceof File && typeof FileReader != 'undefined') {
                var fileName = file.name;
                var type = file.type;
                var reader = new FileReader();
                reader.onload = function (event) {
                    var contents = event.target.result;
                    self.files[fieldName] = {
                        contents: contents,
                        fileName: fileName,
                        type: type
                    };
                };
                reader.readAsDataURL(file);
            }
        },
        preloadFileHandlerAndroid: function (contents, fileName, type) {
            var self = this;
            self.files['filename'] = {
                contents: 'file,' + contents,
                fileName: fileName,
                type: type
            };
        },
        saveButtonHandler: function () {
            $("#save-btn").addClass('ui-disabled');
            var self = this;
            var editViewEl = $('#EditView');
            editViewEl.unbind('submit');
            editViewEl.validate({
                focusInvalid: false,
                invalidHandler: function (form, validator) {
                    $.mobile.silentScroll($(validator.errorList[0].element).position().top);
                }
            });
            editViewEl.submit(function (e) {
                e.preventDefault();
                if ($(e.currentTarget).valid()) {
                    self.showLoadingMessage();
                    self.fetchFromForm();
                    self.trigger('save');
                } else {
                    $.mobile.hidePageLoadingMsg();
                    $("#save-btn").removeClass('ui-disabled');
                }
            });
            editViewEl.submit();
        },
        cancelButtonHandler: function () {
            this.trigger('cancel');
        },
        deleteButtonHandler: function () {
            if (confirm("Are you sure you want to delete the entry?")) {
                this.trigger('delete');
            }
        },
        footerItems: function () {
            return [{
                type: 'link',
                id: 'save-btn',
                disabled: false,
                text: 'Save',
                icon: 'check',
            }, {
                type: 'link',
                id: 'cancel-btn',
                disabled: false,
                text: 'Cancel',
                icon: 'back',
            }, {
                type: 'link',
                id: 'delete-btn',
                disabled: (this.model.isNew()),
                text: 'Delete',
                icon: 'delete',
            }];
        },
        params: function () {
            return {
                model: this.model,
                header: this.getHeader()
            };
        },
        _sanitizeMultienumFields: function (formDataArray) {
            var multiselectFields = new Array();
            $.each($("#EditView select[multiple]"), function (i, fileEl) {
                multiselectFields.push(fileEl.name);
            });
            var arr = new Array();
            for (i in formDataArray) {
                if (multiselectFields.indexOf(formDataArray[i].name) == -1) {
                    arr.push(formDataArray[i]);
                }
            }
            formDataArray = arr;
            for (i in multiselectFields) {
                var name = multiselectFields[i];
                var keys = new Array();
                $.each($("#EditView select[name='" + name + "'] option:selected"), function (j, option) {
                    keys.push($(option).val());
                });
                formDataArray.push({
                    name: name,
                    value: '^' + keys.join('^,^') + '^'
                });
            }
            return formDataArray;
        },
        _sanitizeFileFields: function (formDataArray) {
            _.each(this.files, function (fileData, fieldName) {
                formDataArray.push({
                    name: fieldName,
                    value: fileData.fileName
                });
                formDataArray.push({
                    name: fieldName + '_contents',
                    value: fileData.contents
                });
            });
            return formDataArray;
        },
        _sanitizeCheckboxFields: function (formDataArray) {
            $.each($("#EditView input[type='checkbox']"), function (i, elm) {
                if (!elm.checked) {
                    formDataArray.push({
                        name: elm.name,
                        value: false
                    });
                }
            });
            return formDataArray;
        },
        fetchFromForm: function () {
            var formDataArray = $("#EditView").serializeArray();
            formDataArray = this._sanitizeMultienumFields(formDataArray);
            formDataArray = this._sanitizeFileFields(formDataArray);
            formDataArray = this._sanitizeCheckboxFields(formDataArray);
            for (i in formDataArray) {
                this.model.set(formDataArray[i].name, formDataArray[i].value);
            };
        },
        render: function () {
            if (this.model.get('deleted') == 1) {
                this.isSugarTpl = false;
                this.module = false;
                this.tpl = 'DeletedEntry';
            }
            root.BaseView.prototype.render.apply(this, arguments);
            $.each($("#EditView [required]"), function (i, elm) {
                $(elm).addClass('required');
            });
            $.each($("#EditView input[type='email']"), function (i, elm) {
                $(elm).addClass('email');
            });
            this.scrollToTop();
        },
        getHeader: function () {
            var moduleTitle = this.helper.language.translateEnum(this.module, 'moduleList');
            if (!this.model.isNew()) {
                return '<a href="#' + this.module + '">' + moduleTitle + '</a>' + ' > ' + this.model.get('name');
            } else {
                return '<a href="#' + this.module + '">' + moduleTitle + '</a>' + ' > ' + this.helper.string('Create');
            }
        },
        duplicateConfirm: function () {
            return (confirm(this.helper.string('The record you are about to create might be a duplicate of a record that already exists. Create new?'))) ? true : false;
        }
    });
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.SubpanelView = Backbone.View.extend({
        subpanel: false,
        tpl: 'Subpanel',
        initialize: function () {
            Backbone.View.prototype.initialize.apply(this, arguments);
            this.subpanel = this.options.subpanel;
            this.helper = this.options.helper;
        },
        params: function () {
            return {
                subpanel: this.subpanel,
                subpanelTitle: this.getTitle(),
                helper: this.helper
            };
        },
        getTitle: function () {
            if (this.subpanel.label) {
                return this.helper.language.translate(this.subpanel.label, this.subpanel.moduleName);
            } else {
                return this.helper.language.translateEnum(this.subpanel.relatedModule, 'moduleList');
            }
        },
        getContent: function () {
            $("#subpanels-container").parent().show();
            return root.App.renderTemplate(this.tpl, this.params());
        }
    });
    var root = this;
}).call(this);
(function () {
    "use strict"
    this.FooterView = Backbone.View.extend({
        el: '#footer',
        tpl: 'Footer',
        items: [],
        helper: null,
        initialize: function () {
            this.template = $("#" + this.tpl).html();
            _.bindAll(this, 'render');
            this.items = this.options.items;
            this.helper = this.options.helper;
        },
        params: function () {
            return {
                items: this.items,
                helper: this.helper
            }
        },
        render: function () {
            this.params();
            this.$el.html(App.renderTemplate(this.tpl, this.params()));
        }
    });
}).call(this);
(function () {
    "use strict"
    this.Subpanel = function (data) {
        this.moduleName = data.moduleName;
        this.moduleId = data.moduleId;
        this.linkFieldName = data.linkFieldName;
        this.relatedModule = data.relatedModule;
        this.label = data.label;
    };
    _.extend(this.Subpanel.prototype, {
        count: false,
        fetch: function () {
            var self = this;
            return App.restCall('getRelatedCount', {
                data: {
                    moduleName: this.moduleName,
                    moduleId: this.moduleId,
                    linkFieldName: this.linkFieldName,
                },
                success: function (result) {
                    self.setCount(result);
                }
            });
        },
        setCount: function (count) {
            this.count = count;
            this.trigger('change');
        }
    }, Backbone.Events);
}).call(this);
(function () {
    "use strict"
    this.SubpanelController = function (model, viewFactory) {
        this.model = model;
        this.viewFactory = viewFactory;
        root.subpanelDefs = [];
        var url;
        if (App.flav == 'lite') {
            url = "defs/" + this.model.module + "/subpanels.js";
        } else {
            url = App.sugarUrl + 'index.php?entryPoint=getMobileSubpanelDefs&module=' + this.model.module;
        }
        App.include(url, {
            error: function () {}
        });
        this.defs = root.subpanelDefs;
        _.bindAll(this, 'process');
    };
    _.extend(this.SubpanelController.prototype, {
        process: function () {
            if (typeof SubpanelView == 'undefined') {
                App.include('jetMobile/views/SubpanelView.js');
            }
            if (typeof Subpanel == 'undefined') {
                App.include("jetMobile/Subpanel.js");
            }
            var html = '';
            var self = this;
            var subpanels = {};
            _.each(this.defs, function (defs) {
                var subpanel = new Subpanel({
                    moduleName: self.model.module,
                    moduleId: self.model.id,
                    linkFieldName: defs.linkFieldName,
                    relatedModule: defs.relatedModule,
                    label: (typeof defs.label != 'undefined') ? defs.label : false
                });
                subpanels[defs.linkFieldName] = subpanel;
                var subpanelView = self.viewFactory.create('Subpanel', {
                    subpanel: subpanel
                });
                $("#subpanels-container").append(subpanelView.getContent());
                subpanel.bind('change', function () {
                    $("#subpanels-container #subpanel-" + defs['linkFieldName'] + " .count ").html(subpanel.count);
                });
                subpanel.fetch();
            });
            $("#page").trigger('create');
        },
        getRelatedModule: function (linkFieldName) {
            var relatedModule = false;
            _.each(this.defs, function (defs) {
                if (defs.linkFieldName == linkFieldName) {
                    relatedModule = defs.relatedModule;
                    return;
                }
            });
            return relatedModule;
        }
    });
    var root = this;
}).call(this);